Android: AppWidget开发官方文档

本文详细介绍了Android AppWidget中使用集合数据保持内容新鲜的方法。通过AppWidgetManager的notifyAppWidgetViewDataChanged()方法触发RemoteViewsFactory的onDataSetChanged()回调来更新数据。此过程允许开发者在不增加内存负担的情况下为用户提供最新的内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. AppWidget设计概述

http://developer.android.com/design/patterns/widgets.html

 

2. AppWidget设计指南

http://developer.android.com/guide/practices/ui_guidelines/widget_design.html#anatomy_determining_size

 

3. AppWidget详细介绍

http://developer.android.com/guide/topics/appwidgets/index.html

 

4. AppWidgetProvider: 实现AppWidget provider

http://developer.android.com/reference/android/appwidget/AppWidgetProvider.html

 

5. AppWidgetProviderInfo: 描述AppWidget provider元数据,与 <appwidget-provider> xml标签对应

http://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo.html

 

6. AppWidgetHost

http://developer.android.com/reference/android/appwidget/AppWidgetHost.html

 

 

Keeping Collection Data Fresh

The following figure illustrates the flow that occurs in an app widget that uses collections when updates occur. It shows how the app widget code interacts with the RemoteViewsFactory, and how you can trigger updates:

One feature of app widgets that use collections is the ability to provide users with up-to-date content. For example, consider the Android 3.0 Gmail app widget, which provides users with a snapshot of their inbox. To make this possible, you need to be able to trigger your RemoteViewsFactory and collection view to fetch and display new data. You achieve this with the AppWidgetManager call notifyAppWidgetViewDataChanged(). This call results in a callback to your RemoteViewsFactory’s onDataSetChanged() method, which gives you the opportunity to fetch any new data. Note that you can perform processing-intensive operations synchronously within theonDataSetChanged() callback. You are guaranteed that this call will be completed before the metadata or view data is fetched from the RemoteViewsFactory. In addition, you can perform processing-intensive operations within the getViewAt() method. If this call takes a long time, the loading view (specified by theRemoteViewsFactory’s getLoadingView() method) will be displayed in the corresponding position of the collection view until it returns.

转载于:https://www.cnblogs.com/veins/p/3829286.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值