android之知识点小结一

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

大家好,又见面了,我是全栈君。

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-data
								android: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-data
	android: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>

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/121416.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Redis学习——redis.conf 配置文件介绍

    学以致用 学在用前参看文章: redis.conf配置详细解析 redis.conf 配置详解 Redis配置文件详解(redis.conf)-云栖社区在Redis的使用过程,除了知道对Redis五种数据类型的操作方法之外,最主要额就是对redis.conf进行配置了,下面整理出redis.conf中常见的一些配置介绍。 参数说明 redis.conf 配置项说…

    2022年2月26日
    47
  • 查看linux执行的命令记录_shell 调用history

    查看linux执行的命令记录_shell 调用history前言我们每次敲打linux命令的时候,有时候想用之前用过的命令,一般情况下,我们都会按↑↓箭头来寻找历史的命令记录,那如果我想用1天前执行的某条命令,难道还要按↑100次?显示这样是不现实的,我们可

    2022年7月31日
    9
  • sdk e qq(E+)

    1.说明:教程属于官方E聊SDK-简介(1)进入官网进入管理台SDK版本:v1.01技术交流QQ群:4716889372.简介:E聊SDK是一套适用于PC端,移动端的即时通讯解决方案,源代码开放。E聊整合了即时通讯的基础能力,使用E聊,您可以让您的应用快速接入即时聊天的功能。E聊现已适配PCWeb,移动Web,Android,iOS等平台。3.系统架构:3.1各模块介绍E聊服务器:提供了基础的消息转发功能,用户管理、群组管理等功能;E聊管理台:向E聊服务器申请接入

    2022年4月18日
    68
  • js数组怎么删除指定元素_给数组添加一个元素的方法

    js数组怎么删除指定元素_给数组添加一个元素的方法js数组是js部分非常重要的知识,有时我们有这么个需求js数组删除指定元素,先定义一个函数来获取删除指定元素索引值,然后用js数组删除的方法,来删除指定元素即可,就两步不难,很简单。1、JS的数组对象定义一个函数,用于查找指定的元素在数组中的位置,也就是索引值,代码如下: 1 2 3 4 5 6 Array….

    2022年9月27日
    3
  • POJ 3076 SUKODU [Dangcing Links DLX精准覆盖]「建议收藏」

    POJ 3076 SUKODU [Dangcing Links DLX精准覆盖]

    2022年2月7日
    55
  • Cocos2D-X2.2.3学习笔记8(处理精灵单击、双击和三连击事件)

    Cocos2D-X2.2.3学习笔记8(处理精灵单击、双击和三连击事件)

    2021年12月3日
    48

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号