How do you incorporate TextSwitcher on top of a Button?
I wanted the text on my buttons to switch every time that I click it. The only way I know how to switch text is Textswitcher, but I can't seem to find a way to use it with the buttons. I'm sure this is a simple answer and appreciate 开发者_StackOverflowany help!
XML file portion...
Button
android:id="@+id/Button_A"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textSize="@dimen/help_text_size"
android:minWidth="10px"
Java:
Button alphaButton = (Button) findViewById(R.id.Button_A);
alphaButton.setText(mGameSettings.getString(GAME_PREFERENCES_RIGHT, ""));
alphaButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
handleAnswerAndShowNextQuestion("a");
}
});
I'm pretty sure you should just be able to call Button#setText()
in the onClick
listener
精彩评论