How to change the text of a Button widget in Android?(如何在Android中更改Button控件的文本?)
问题描述
如何在代码中而不是在XML文件中更改Android按钮小工具的文本?
推荐答案
我可以这样更改按钮的文本:
import android.widget.RemoteViews;
//grab the layout, then set the text of the Button called R.id.Counter:
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.my_layout);
remoteViews.setTextViewText(R.id.Counter, "Set button text here");
这篇关于如何在Android中更改Button控件的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!