Android – change the text of the button in the program

The text on my button is set in the resource file. For example

            <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 string / up with text @ string_ Button for label text. How to change this text in the application while the application is running

thank you.

resolvent:

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

Maybe it will help

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>