Alex Rivera | Logout

How to change the text of a Button widget in Android?

Asked 2010-10-03T20:37:27.037
45

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

Edit
Report

1 Answer

23

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 R.id.Counter:
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.my_layout);
remoteViews.setTextViewText(R.id.Counter, "Set button text here");
answered 2010-10-06T08:27:58.133

Your Answer