3

Can anyone give me an example of using a Stack Widget and being able to remove and add views dynamically.

Here is an example.

1) Widget loads and you add 4 views to the widget 2) User loads and activity within the same widget package and uses a button to delete one of the 4 views.

I need an example how to do that.

Thanks for the help!!

1 Answer 1

3

Your StackView widget should have an implemntation of the RemoteViewsService.RemoteViewsFactory interface which includes the onDataSetChanged() method. Within this method you need to update the widget from your data source.

Then in your application, any time your data set changes you can then tell any instances of your widget to refresh themselves by calling:

AppWidgetManager awm = AppWidgetManager.getInstance(getActivity()); awm.notifyAppWidgetViewDataChanged(awm.getAppWidgetIds(new ComponentName(getActivity(), Your_App_Widget_Provider.class)), R.id.your_stack_view);

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.