Reputation: 6960
I wan't to add button
to android widget
dynamically.
I've tried to do it by following way from main Activty
:
Button a = new Button(this); a.setText("Pushme"); RelativeLayout rl = (RelativeLayout)findViewById(R.id.llay); rl.addView(a);
RelativeLayout
here it's widget
layout.
From AppWidgetProvider
custom class I cant do it too, cause I'm unable to create there button.
Is there any solution?
Upvotes: 0
Views: 1850
Reputation: 1007359
You can call addView()
on a RemoteViews
to add a nested RemoteViews
.
Or, define all your buttons in your base layout that you use with RemoteViews
, with some buttons initially set to android:visibility="gone"
. Then, use setViewVisibility()
on the RemoteViews
to make them visible as desired.
Upvotes: 1