现在的位置: 首页 > 综合 > 正文

widget

2013年12月11日 ⁄ 综合 ⁄ 共 1245字 ⁄ 字号 评论关闭

1. AppWidget framework 

    widgets放在桌面,供用户进行交互。我们通过widgets来"窥视"某个完整应用的一些情况。例如开发显示后台音乐的信息的widget。

 

2.用XML来描述widget
如果希望widget在桌面占据的位置为 宽=2*cell, 高=1*cell ,通过以下的公式转换为dip单位:
Minimum
size in dip = (Number of cells * 74dip) - 2dip
宽=146dip, 高=72dip 

 

BroadcastReceiver

RemoteViews 

 

 

步 骤

1.在manifest中声明widget.

   widget由一个AppWidgetProvider(BroadcastReceive的子类)定义,AppWidgetProvider为widget提供了方便的操作。该BroadcastReceive接收PPWIDGET_UPDATE的广播。

   widget的layout,更新频率和AppWidgetProvider类是由AppWidgetProviderInfo
对象来定义,这个对象是由<meta-data>定义。

  

 

2. AppWidgetProviderInfo

 

3. Creating the App Widget Layout

 

A RemoteViews object (and, consequently, an App Widget) can support the
following layout classes:

And the following widget classes:

Descendants of these classes are not supported.

 

4. AppWidgetProvider 

   such as when the App Widget is updated, deleted, enabled, and disabled. When
these broadcast events occur, the AppWidgetProvider receives the following
method calls:

   OnUpdate:

抱歉!评论已关闭.