Android_Action和Category属性
来源:互联网 发布:遮挡照片的软件 编辑:程序博客网 时间:2024/05/29 07:58
package com.example.intentdemo3;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;public class MainActivity extends Activity implements OnClickListener{ Button btn; String str="com.example.intentdemo3.action.ITSZI_ACTION";// String str="android.intent.action.ITSZI_ACTION"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btn=(Button)findViewById(R.id.button1); btn.setOnClickListener(this); } @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent=new Intent(); intent.setAction(str); startActivity(intent); }}package com.example.intentdemo3;import android.app.Activity;import android.os.Bundle;import android.widget.TextView;public class SActivity extends Activity { TextView text; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_s); text=(TextView)findViewById(R.id.text); String str=getIntent().getAction(); text.setText(str); }}
这两个都是Activity
,第一是主Activity,xml
文件中有一个按钮,通过这个按钮,跳转到SActivity
这个Activity
中,它里面包含一个TextView
,显示的内容是Action
.
需要注意的地方如下
(1).在SActivity
中TextView
的对象,显示的文本信息是自己的Action
(2)可以自定义AndroidManifest.xml
中的action
,保证是字符串即可。
(3)SActivvity
中的action
和category
的标签内容需要自己添加。
需要注意的是category
的内容需要设置为android.intent.category.DEFAULT
(不可以不设置,这句话必须存在),表示为默认;
也可以自定义添加一个category
(4)MainActivity
中获得Action
的值,并进行跳转
setAction
中的内容就是SActivity
中的action
的值
(5)SActivity
中在TextView
对象text
文本中显示,action
和category
。
注意的是他们的返回值是不一样的,一个是集合,一个是字符串。
介绍Action和Category的关系
举一个例子,一个女孩子找男朋友,她有一些要求:男性、高、富、帅。
男性相当于Action
,Action
这能有一个
高富帅相当于Category
,Category
可以有很多
而一个男性有很多特点,满足了很多女孩系择偶的标准,用如下图表示
阅读全文
0 0
- Android_Action和Category属性
- ios Category 和 extension 区别,Category中使用属性
- 为category添加属性和成员变量
- Category中的属性和成员变量
- 5 返回桌面 Intent的action 和 category 属性
- 安卓学习笔记--Intent的属性action和category
- Category 笔记 最新理解和动态添加属性
- runtime结合category和block动态增加方法以及属性
- iOS Category中添加属性和成员变量的区别
- 给Category添加属性
- Category添加属性
- category添加属性
- category动态添加属性
- Category中的属性
- Category添加属性字段
- Category 动态添加属性
- 给category增加属性
- 给category增加属性
- ThreadLocal与ThreadLocalMap源码解析
- Spark成长之路(8)-TFIDF
- 剑指offer面试题[54]-表示数值的字符串
- fatcache源码阅读记录
- 【Redis基础】发布与订阅
- Android_Action和Category属性
- android,actionbar,menu显示,图片,菜单禁用★★★
- 草稿
- asp.net不允许访问.json文件的解决办法
- Spring(四)(springaop的实现)
- js
- AtomicInteger类的理解与使用
- Spring MVC拦截器简介
- Spring的两种事务定义方式