guilherme.minglini
guilherme.minglini

Reputation: 564

Accessing elements of a widget from the AppWidgetProvider

I have built a widget that contains an ImageButton.

How can I access the imagebutton from an AppWidgetProvider and add an click listener on it (to change the color of the button, for example)?

In an Activity I would just use findViewById() and setOnClickListener(), but I can't do that in the AppWidgetProvider.

Upvotes: 2

Views: 596

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007658

How can I access the imagebutton from an AppWidgetProvider and add an click listener on it (to change the color of the button, for example)?

You put the click listener on it when you create it via the RemoteViews. You cannot access it later. If you wish to change it, update the app widget with a new RemoteViews.

Upvotes: 1

Related Questions