打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
RemoteView总结 - 追求幸福 - JavaEye技术网站
我最初认识RemoteView是在AppWidget里面的,但当时由于刚接触1个月andrdoid就开始做一个appWidget,对其的用法与作用不是很清楚,最近再次接触其,才明白其作用。

到目前为止,我发现RemoteView会用在两个地方:一个是在AppWidget,另外一个是在Notification.

先从官方对他的定义来看:
RemoteView--
A class that describes a view hierarchy that can be displayed in another process. The hierarchy is inflated from a layout resource file, and this class provides some basic operations for modifying the content of the inflated hierarchy.

RemoteView描述一个view,而这个view是在另外一个进程显示的。它inflate于layout资源文件。并且提供了可以修改过view内容的一些简单基础的操作。

从这个定义我们就知道RemoteView是用来描述一个垮进程显示的view。从而你就会明白为什么AppWidget和Nofication需要用到它了。
1,AppWidget---RemoteView
我们都知道AppWidgetProvider是一个BrocaseReceiver,只是接受到Enable, Update,disale,delete这些message,而真正显示界面的是AppWidgetHostView(这是在Launcher里面实现的)这中间就是通过RemoteView来沟通。通过RemoteView告诉Launcher你想要的AppWidget是长什么样。

2,Notification--RemoteView
若你想自定义你的Notification也必须通过RemoteView.因为你定义的Nofication和显示Notification也是两个不同的进程。

在android 2.2之前,RemoteView只支持一些简单的view:TextView, Framelaout..不支持ListView和GridView等复杂的view,它的操作也是简单的click.在网上有人说是通过@RemoteView这个标签确定RemoteView是否支持view.在view的源文件加上@RemoteView这个标签就可以支持了。这个我还没有去试试过。

在android 3.0,Google加强这方面,下面来源官方文档:
Expanded Home screen widgets

Home screen widgets are popular with users because they offer fast access to application-specific data directly from the home screen. Android 3.0 lets developers take home screen widgets to the next level, offering more types of content and new modes of interaction with users. Developers can now use more standard UI widget types home screen widgets, including widgets that let users flip through collections of content as 3D stacks, grids, or lists. Users can interact with the home screen widgets in new ways, such as by using touch gestures to scroll and flip the content displayed in a widget.

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Android AppWidget如何支持复杂的View
从零开始创建一个Android主屏幕Widget
更新appWidget时,LogCat中出现 !!! FAILED BINDER TRANSACTION !!!
Android桌面小插件的开发详解
转载一份 关于appwidget 很详细
App Widget的更新方法介绍
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服