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)
上一篇 2022年3月10日 下午1:00
下一篇 2022年3月10日 下午2:00


相关推荐

  • java文件服务器搭建(如何搭建服务器)

    一.服务器的购买1.我选择的是阿里云的服务器,学生价9.5元一个月,百度直接搜索阿里云,然后点击右上角登录,推荐大家用支付宝扫码登录,方便快捷。阿里云官网的东西比较多,登录后我找了很久也没有找到学生服务器在哪里卖,最后在咨询里找到了这个网址,https://promotion.aliyun.com/ntms/campus2017.html,购买的时候需要进行学生认证,按照他的要求一步步…

    2022年4月18日
    54
  • android 触屏处理流程,android触摸事件处理流程 ? FOOKWOOD「建议收藏」

    android 触屏处理流程,android触摸事件处理流程 ? FOOKWOOD「建议收藏」最近在工作中,经常需要处理触摸事件,但是有时候会出现一些奇怪的bug,比如有时候会检测不到ACTION_MOVE和ACTION_UP,我决定下决心写个测试的小程序,来研究一个触摸事件从上往下是怎么传递和处理的。先说下大概的流程吧,这个应该在很多博客中都有讲解:当一个事件来临的时候,会先传递给最外层的ViewGroup(比如LinearLayout,FrameLayout),如果这个ViewGrou…

    2025年10月24日
    6
  • github代理地址

    github代理地址GitHubProxy 代理加速 https ghproxy com 在访问和下载 gitlab 的时候 有时会很慢可以用代理访问 gitclonegitc ghproxy com https github com stilleshan ServerStatus amp curlwgethttp ghproxy com https github com stilleshan ServerStatus arch

    2026年3月19日
    3
  • 八叉树建立地图并实现路径规划导航

    八叉树建立地图并实现路径规划导航构建语义地图时 用的是 octomap server 和 semantic slam octomap generator 不过还是整理下之前的学习笔记 一 Octomap 安装并使用 Octomap Server1 1Apt 安装 Octomap 库如果你不需要修改源码 可以直接安装编译好的 octomap 库 记得把 ROS 版本 kinetic 替换成你用的 sudoapt getinstallro kinetic octomap 上面这一行命令等价于安装以下的 octomap 组件

    2026年3月16日
    5
  • matlab读取txt数据文件「建议收藏」

    matlab读取txt数据文件「建议收藏」一、load()函数load函数适合读取纯数据文本例子,data_txt.txt内容如下:0  1.000000  2.000000  3.0000001  3.000000  4.000000  5.0000002  6.000000  7.000000  8.0000003  9.000000  10.00000  11.00000读取代码如下:%对于类似的txt文件,不含有字符,只有数字data=load(‘data_tx…

    2025年9月19日
    7
  • 详解IPv4地址

    详解IPv4地址IPv4 地址范围 0 0 0 0 255 255 255 255 约有 43 亿 计算机的 IP 地址由两部分组成 一部分为网络位 一部分为主机位 同一网段内的计算机网络部分相同 主机部分不同同时重复出现 路由器连接不同网段 负责不同网段之间的数据转发 交换机连接的是同一网段的计算机 通过设置网络地址和主机地址 在互相连接的整个网络中保证每台主机的 IP 地址不会互相重叠 即 IP 地址具有了唯一性 网络掩码 用于区分一个 IP 地址的网络部分和主机部分 IP 地址根据网络 ID 的不同分为 A

    2026年3月19日
    2

发表回复

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

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