Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the text on a button in the program

Tags:

android

button

The text on my buttons are set in resource files. E.g.

            <Button android:id="@+id/up_button" android:layout_width="fill_parent"
                android:layout_height="wrap_content" android:text="@string/up_label" />

The above code defines a button with text @string/up_label. How can I change this text in my program during the application is running.

Thanks.

like image 950
Yin Zhu Avatar asked Dec 12 '22 18:12

Yin Zhu


1 Answers

Button myButton = (Button) findViewById(R.id.up_button);
myButton.setText("my text");

maybe this will help.

like image 86
Marco Schmid Avatar answered Jan 20 '23 00:01

Marco Schmid