我的按钮上的文本在资源文件中设置.例如
<Button android:id="@+id/up_button" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/up_label" />
Run Code Online (Sandbox Code Playgroud)
上面的代码定义了一个带文本的按钮@string/up_label.如何在应用程序运行期间更改程序中的此文本.
谢谢.
小智 8
Button myButton = (Button) findViewById(R.id.up_button);
myButton.setText("my text");
Run Code Online (Sandbox Code Playgroud)
也许这会有所帮助.
或者,如果您在资源中有新文本(我认为是这样),则可以
Button myButton = (Button) findViewById(R.id.up_button);
myButton.setText(R.string.down_label);
Run Code Online (Sandbox Code Playgroud)
down_label字符串的ID 在哪里。
| 归档时间: |
|
| 查看次数: |
10859 次 |
| 最近记录: |