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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Java遍历Map效率对比

    Java遍历Map效率对比Java中Map容器的遍历有多种方式,但是不同的方式效率会大有不同,以前没有注意这些细节,随意使用遍历方式在本地可能没有什么影响,但是在项目在高频使用需要特别注意,尽量使用高效的方式。首先,Map.Entry<K,V>是可以包含了Key和Value的,keySet包含了所有的Key,再使用get方法可以拿到对应的Value;所以包含Key和Value内容…

    2022年4月7日
    65
  • Xshell 连接linux主机

    Xshell 连接linux主机0 前言使用 Xshell 连接远程服务器 文件 新建 出现如下图标 主机即为需要连接的 Linux 服务器的 ip 地址 端口号为 22 无须修改 但需要确认远程服务器的 22 端口已经打开 点击左边的 用户身份验证 输入用户名和密码 点击确认后 即可连接 总体流程 就是这个样子 问题就在于 ip 地址 用户名 密码怎么填写 下面几个章节就展示了如何查看远程 Linux 服务器的 ip 用户名和密码等 1 查看 ip 地址查看 ip 地址使用命令 ifconfig 确保能够 ping 通在连接之前 需要确保本地能够 p

    2025年7月11日
    4
  • goland 激活码3月最新在线激活「建议收藏」

    goland 激活码3月最新在线激活,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月14日
    42
  • VB学习总结「建议收藏」

    VB学习总结「建议收藏」无论是生活还是学习,都要不断的总结和思考。学习中,不可以偷懒,你对它偷懒,它就会对你更加偷懒;同样,没有规律和反思的生活是平淡如水,没有进步的,今天的我们应该能和昨天面对面,每天进步一点点。   这次的总结是对全部模块的总结,记录此刻的学习轨迹,以供以后反思学习,同时分享给大家,欢迎大家批评建议。      1.总结大纲——时间管理,计划同步    2.

    2022年6月21日
    22
  • JavaScript如何判断一个值是不是数字?「建议收藏」

    JavaScript如何判断一个值是不是数字?「建议收藏」第一种方法:isNaN()使用js自带全局函数isNaN(),isNaN()返回一个Boolean值,如下:varc="hello";//字符串isNaN(c);//返回一个false;varc=10;//数字inNaN(c);//返回一个true如果以上c为一个空串或是一个空格,isNaN将把c当作数字0来处理,所以检查不严谨。第二种方法:正则表达式functioncheckNu…

    2022年4月20日
    45
  • 如何把pyc反编译成py_exe文件反编译源码工具

    如何把pyc反编译成py_exe文件反编译源码工具将pyc文件反编译成python源代码

    2022年8月23日
    6

发表回复

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

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