本文翻译整理自:<wbr style="line-height:22px"><span style="line-height:22px; font-family:Arial,Helvetica,simsun,u5b8bu4f53"><a rel="nofollow" href="http://developer.android.com/guide/topics/appwidgets/index.html#implementing_collections" style="color:rgb(207,121,28); line-height:22px; text-decoration:none">http://developer.android.com/guide/topics/appwidgets/index.html#implementing_collections</a></span></wbr>
3.7、数据更新
图2
说明了App Widget with Collections如何进行数据更新。它也给我们展示了App Widget代码如何和RemoteViewsFactory进行交互, 和我们App Widget with Collections
应该如何请求进行数据更新。
图2
调用了该方法之后,系统会对RemoteViewsFactory的onDataSetChanged()方法进行回调, 在这里你可以进行最新数据的提取.
注意
:你可以在 onDataSetChanged()回调函数中做一些耗时工作(同步的)的处理。系统将保证这些操作在从RemoteViewsFactory返回新数据的信息或View之前完成。
另外, 你可以在getViewAt()返回中进行耗时操作的处理. 如果getViewAt()超过一定的时限,系统就先用RemoteViewsFactory的getLoadingView()返回的View进行显示,直到getViewAt()完成。
评论这张
转发至微博