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输出结果保留两位小数

    Java输出结果保留两位小数Java输出结果保留两位小数

    2022年7月8日
    35
  • Linux安装vim命令

    Linux安装vim命令最近在Linux上使用vim编辑器编写shell脚本的时候,遇到了这样一个问题,如下:-bash:vim:commandnotfound这是因为vim命令没有安装,于是我从网上搜索了很多关于安装vim命令的教程,不过大都比较繁琐,如今介绍一种简单的方法,大家可以试一下。首先,执行如下命令进行查询:rpm-qa|grepv…

    2025年8月11日
    2
  • 背英语四级单词的三个小’窍门

    背英语四级单词的三个小’窍门

    2021年5月2日
    121
  • bt3硬盘安装_SD卡比U盘音质好

    bt3硬盘安装_SD卡比U盘音质好在U盘/SD卡上安装BT3教程(激活成功教程无线路由信号密码必备)其实网上关于BT3的教程很多,如果大家根据下面的教程安装不成功的话,可以再去百度一下其它的教程。前几天写过一个帖子是关于如何用BT3激活成功教程路由信号的(点我查看),为了引起关注,放在了Win区。在那个帖子里我是将

    2022年10月1日
    2
  • RPN网络通俗理解

    RPN网络通俗理解【提特征】RPN网络前面是一个提特征的网络,比如VGG,Res等,传给RPN网络的是一个特征图,其实也就是一个tensor比如用ZF网络(论文里面用的)输出特征图:13*13*256【RPN】拿到模型的特征,RPN网络首先加了一个3*3*256*256的卷积层(其实不是很清楚为什么加,可能是为了扩大感受野)这样就会得到11*11*256的输出,前面11*11是图形矩阵,其中每一个点在原图中都是一个…

    2022年6月23日
    36
  • 灰色预测模型_用excel作灰色预测步骤

    灰色预测模型_用excel作灰色预测步骤灰色预测模型是通过少量的、不完全的信息,建立数学模型并作出预测的一种预测方法。灰色系统理论是研究解决灰色系统分析、建模、预测、决策和控制的理论。灰色预测是对灰色系统所做的预测。目前常用的一些预测方

    2022年8月6日
    6

发表回复

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

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