【问题标题】:how to partially Update AppWidget如何部分更新 AppWidget
【发布时间】:2013-07-18 07:24:53
【问题描述】:

我正在编写一个 AppWidget,它有一个视图(例如 Textview)显示用户选择的信息,我希望我的 UI 事件处理程序在每次触发 UI 事件时仅更新文本视图,问题是我该怎么做仅通过 Remoteviews 更新 Textview,是 AppWidgetManager 的 partialUpdateAppWidget 方法的解决方案,如果为真,请告诉我它的用法,提前谢谢

【问题讨论】:

  • 不错,如果您发现有用的东西,请添加它

标签: android android-appwidget


【解决方案1】:

如果您将其写入 api 11 及更高版本,请使用:

 // Get the layout for the App Widget  
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
views.setTextViewText(id,text);
appWidgetManager.updateAppWidget(appWidgetId, views);

如本题所示 How to partially update views in an app widget without rebuilding all the RemoteViews

否则重建整个removeviews(基本上再次调用remoteViews)

【讨论】:

    猜你喜欢
    • 2013-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-09
    • 2011-10-20
    相关资源
    最近更新 更多