Skatephone Skatephone - 1 year ago 109
Android Question

Android widget: How to change the text of a button

How can I change the text of an Android button widget within code and not the XML file?

Answer Source

I was able to change the button's text like this:

import android.widget.RemoteViews;

//grab the layout, then set the text of the Button called
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.my_layout);
remoteViews.setTextViewText(, "Set button text here");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download