How to partially update views in an app widget without rebuilding all the RemoteViews

无人久伴 提交于 2019-12-01 18:24:58
Yanling

Yes, you can use partiallyUpdateAppWidget method in the AppWidgetManager class. As an example, if you want to update a text view inside a widget:

AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
rv = new RemoteViews(context.getPackageName(), R.layout.widgetlayout); 
rv.setTextViewText(R.id.ofTextViewInWidgetLayoutXML, "Hello World");
appWidgetManager.partiallyUpdateAppWidget(appWidgetIds, rv);

Ref: Just update a widget RemoteViews instead of completly creating a new one?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!