We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
基本上,您需要使用两个组件:
让我们创建 RemoteViewsFactory 类:
现在是 RemoteViewsService 的时候了(最简单的):
您还必须在 androidManifest.xml 中注册此服务:
现在在扩展 AppWidgetProvider 的 Widget 类中,您可以管理布局:
现在创建一个新的res/xml 中的资源文件并将其命名为 collection_widget.xml:
我们需要在 res/layout 中再创建两个文件来定义列表的布局以及每个列表项的布局。
collection_widget.xml:
collection_widget_list_item.xml:
我使用这篇文章作为示例,对我来说就像一个魅力!
https:// www.sitepoint.com/killer-way-to-show-a-list-of-items-in-android-collection-widget/
如今,这种情况并不罕见。希望能帮助某人。
Basically, you need to use two components:
Let's create the RemoteViewsFactory class:
Now it's time for the RemoteViewsService (the easy one):
Also you must register this service in the androidManifest.xml:
And now in your Widget class which extends AppWidgetProvider, you can manage the layouts:
Now create a new resource file in res/xml and name it collection_widget.xml:
We need to create two more files in res/layout to define the layout of the list and the layout of each list item.
collection_widget.xml:
collection_widget_list_item.xml:
I use this article like example and works like a charm for me!!
https://www.sitepoint.com/killer-way-to-show-a-list-of-items-in-android-collection-widget/
Now a days, this is not that rare. Hope to help someone.
这只能在 Honeycomb 上实现。早期版本的 Android 不支持此功能,未来的手机是否会支持它还有待观察。
WeatherListWidget 示例位于您的 SDK 中,并且在文档中进行了简单说明。
This is only possible on Honeycomb. Earlier versions of Android did not support this, and it remains to be seen if it will be supported on phones going forward.
The WeatherListWidget sample is in your SDK and is lightly explained in the documentation.