博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
RemoteView概述
阅读量:7034 次
发布时间:2019-06-28

本文共 1783 字,大约阅读时间需要 5 分钟。

hot3.png

1.RemoteView概述

到目前为止,我发现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这个标签就可以支持了。这个我还没有去试试过。 (在htc sence ui 中我们可以看到有用到listview,gridview,这是怎么做到的呢,看下面说明)
在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.

转载于:https://my.oschina.net/u/246578/blog/62906

你可能感兴趣的文章
Ubuntu root权限打开文件夹
查看>>
iOS CollectionView 的那些事
查看>>
Git 使用日常
查看>>
硬派计费免费社区版 V4.0 正式发布
查看>>
开源免费的C/C++网络库(c/c++ sockets library)
查看>>
Nagios监控平台(转)
查看>>
firfox 中onpropertychange的替换方案
查看>>
代码分析工具findbug简介和使用
查看>>
Jquery UI Tabs 获取选中Tab的ID
查看>>
Android Wear开发系列教程——搭建开发环境
查看>>
如何更好地学习dubbo源代码
查看>>
IE、Chrome、Firefox修改http header信息
查看>>
跨平台网络通信与服务器编程框架库(acl库)介绍
查看>>
利用半透明对话框实现新浪微博android客户端首次运行时的提示界面
查看>>
mOrmot 服务端 方法 代码载录
查看>>
php 查找父类所有的子类
查看>>
FAT32中文版分析+补充
查看>>
php 生成 桌面快捷链接
查看>>
使用maven构建android 的apk包并自动签名
查看>>
objective - c 内存管理机制
查看>>