Android Home screen Widget: RemoteViews setRemoteAdapter(…) method not working on API 11+

后端 未结 3 543
悲&欢浪女
悲&欢浪女 2021-02-06 03:09

So onUpdate method calls

remoteViews.setRemoteAdapter(id, R.id.listview, intent)

in order to apply an adapter to the listview in the widget.

<
3条回答
  •  长发绾君心
    2021-02-06 04:05

    The suggested method unfortunately didn't work for me. What worked is calling appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.list_view);

    I have a static method in my AppWidgetProvider class that I call whenever I want to update the widget data. I called this notifyAppWidgetViewDataChanged inside that method and everything worked. Now the widget updates the list data properly.

提交回复
热议问题