Manifest.xml文件中的一些代码作用:

<activity android:name=".LunchList"  android:label="@string/app_name"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter><intent-filter><action android:name="android.intent.action.SEARCH" /><category android:name="android.intent.category.DEFAULT" /></intent-filter><meta-data android:name="android.app.searchable"   android:resource="@xml/searchable" /><meta-data android:name="android.app.default_searchable"   android:value=".LunchList" /></activity>

在上面这段代码中,

<intent-filter>        <action android:name="android.intent.action.SEARCH" />        <category android:name="android.intent.category.DEFAULT" />      </intent-filter>

这个是注册的隐式Intent的过滤器,第二行表示过滤带有搜索action的intent,第三行是必须要添加的(自定义的Activity如果要通过隐式intent启动,则必须添加)

<meta-data android:name="android.app.searchable"  android:resource="@xml/searchable" />

这个是在使用默认的搜索框架是,给搜索框设置的布局,第一行name是给定的,第二行resource就是你给自己的搜索框设置的外观布局,一般放在res/xml里

<meta-data android:name="android.app.default_searchable"           android:value=".LunchList" />

这个也是和搜索相关,上面两个是通过intent_filter过滤接收到intent,以及接收到intent之后显示出来的搜索框的布局,但那样只是在你注册了meta-data节点的activity里面才能执行搜索,如果想要在任意一个activity里面都能启动搜索框架,就要加上这个,这个第一行也是给定的,第二行则用来指定是由哪一个activity响应并执行搜索和显示搜索结果.

<receiver android:name=".AppWidget"android:label="@string/app_name"android:icon="@drawable/icon"><intent-filter><action android:name="android.appwidget.action.APPWIDGET_UPDATE"/><category android:name="android.intent.category.DEFAULT" /></intent-filter><meta-dataandroid:name="android.appwidget.provider"android:resource="@xml/widget_provider" /></receiver>

这段代码中:注册的是一个Widget,其中第二行是widget的标题,第三行是它的图标,

<intent-filter><action android:name="android.appwidget.action.APPWIDGET_UPDATE"/><category android:name="android.intent.category.DEFAULT" /></intent-filter>

这个跟最上面的类似,就是注册了intent的过滤器,过滤widget的更新action,第三行在上面解释过了,这里的更新actiong是放在隐式intent里面的,所以要加上第三行

<meta-dataandroid:name="android.appwidget.provider"android:resource="@xml/widget_provider" />

这个则是对widget的参数配置,第二行是指定的,第三行就是我们自定义的widget参数,放在res/xml下,这里的配置如下:res/xml/widget_provider.xml

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:minWidth="300dip" android:minHeight="79dip" android:updatePeriodMillis="1800000" android:initialLayout="@layout/widget"/>

二三四行分别是宽高和更新频率,第五行则是该widget的具体布局,布局方式与layout里的其他布局方式一样:res/layout/widget.xml

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:background="@drawable/widget_frame"><TextView android:id="@+id/name"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_alignParentLeft="true"android:layout_toLeftOf="@+id/next"android:textSize="10pt"android:textColor="#FFFFFFFF"/><ImageButton android:id="@+id/next"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:layout_alignParentRight="true"android:src="@drawable/ff"/></RelativeLayout>

更多相关文章

  1. android 入门xml布局文件--转
  2. Android 布局属性详解
  3. 【Android】Android 代码判断是否获取ROOT权限(一)
  4. android中的布局文件
  5. android layout布局属性
  6. Android多语言布局layout
  7. Android相对布局属性
  8. 安卓开发笔记(三)android 相对布局属性
  9. Android之布局属性归纳

随机推荐

  1. 总裁发话: 创业者应该如何避免陷入
  2. 藏不住了,Flink 未来发展的最新方向在这里
  3. js基础知识
  4. 利用openwrt编译添加zabbix_proxy3.4.10
  5. iframe与css基础
  6. CSS引入方式与选择器
  7. sed+awk 实现单个文件多行字符合并成单行
  8. C语言5.0
  9. 1Mbps能做什么?
  10. 你说的 Flink 和搜索引擎有什么关系