main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"> <Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按Action值1启动目标Activity" />
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按Action值2启动目标Activity" /> </LinearLayout>

mainactivity.java

package com.sxt.day04_07_twoaction;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener; public class MainActivity extends Activity implements OnClickListener{ @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setListener();
} private void setListener() {
findViewById(R.id.btn1).setOnClickListener(this);
findViewById(R.id.btn2).setOnClickListener(this);
} @Override
public void onClick(View v) {
Intent intent=new Intent();
switch (v.getId()) {
case R.id.btn1:
intent.setAction("com.sxt.day04_07_twoaction.SecondActivity");
break;
case R.id.btn2:
intent.setAction("com.sxt.day04_07_twoaction.SecondActivity2");
break;
}
startActivity(intent);
}
}

第二个.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".SecondActivity" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" /> </RelativeLayout>

第二个.java

package com.sxt.day04_07_twoaction;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu; public class SecondActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
Log.i("main","SecondActivity");
} }

系统描述文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sxt.day04_07_twoaction"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.sxt.day04_07_twoaction.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.sxt.day04_07_twoaction.SecondActivity"
android:label="@string/title_activity_second" >
<intent-filter> 给SecondActivity设置intent-filter
<action android:name="com.sxt.day04_07_twoaction.SecondActivity"/>com.sxt.day04_07_twoaction.SecondActivity可以随便写
<action android:name="com.sxt.day04_07_twoaction.SecondActivity2"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application> </manifest>

android 22 启动带2个action值的预定义acticity的更多相关文章

  1. android 23 启动带2个Categories值的预定义acticity和桌面activity

    mainActivity.java package com.sxt.day04_07_twoaction; import android.os.Bundle; import android.app.A ...

  2. Android 外部启动activity,自定义action,action常量大全

    从任意app,启动另外一个app的activity: 1.   Intent i = new Intent();           ComponentName cn = new ComponentN ...

  3. Windows自带Android模拟器启动失败

    Windows自带Android模拟器启动失败 错误信息:[Critical] XDE Exit Code: InvalidArguments (3)XDE执行的第三个参数为设置内存值,形式为/mem ...

  4. 使用预定义的action值启动系统应用

    1.启动浏览器 Intent intent = new Intent(); intent.setAction(Intent.ACTION_WEB_SEARCH); //可以传一个搜索关键字,会直接显示 ...

  5. 066 01 Android 零基础入门 01 Java基础语法 08 Java方法 02 带参有返回值方法

    066 01 Android 零基础入门 01 Java基础语法 08 Java方法 04 带参有返回值方法 本文知识点:带参有返回值方法 说明:因为时间紧张,本人写博客过程中只是对知识点的关键步骤进 ...

  6. 065 01 Android 零基础入门 01 Java基础语法 08 Java方法 02 带参无返回值方法

    065 01 Android 零基础入门 01 Java基础语法 08 Java方法 03 带参无返回值方法 本文知识点:带参无返回值方法 说明:因为时间紧张,本人写博客过程中只是对知识点的关键步骤进 ...

  7. Android SurfaceView实战 带你玩转flabby bird (下)

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/43063331,本文出自:[张鸿洋的博客] 1.概述 在Android Surfa ...

  8. Android WIFI 启动流程(TIP^^)

    前几天因为解决一堆Bug,没时间写.我不会每天都写,就是为了存档一些资料. 内容来源:工作中接触到的+高手博客+文档(Books)=自己理解 仅限参考^^ 此博客是上一个<<Android ...

  9. AndroidManifest.xml解释说明和android的启动过程

    1.android清单文件:AndroidManifest.xml 说明如下: <?xml version="1.0" encoding="utf-8"? ...

随机推荐

  1. easy UI demo 含数据库加载示例

    easyUI 部分代码在Googlecode 托管时而被抢此文件包含了所有官方demo,作为备份 下载地址http://pan.baidu.com/s/1pJ9hS5H

  2. finalspeed服务器端和客户端安装

    https://www.91yun.org/archives/2775 https://www.91yun.org/archives/615 1.首先安装服务器端:一键安装代码 wget -N --n ...

  3. 【原】K3Cloud平台开发之Python插件

    有时候我们的表单可能很简单,只是一个简单交互的表单,但有可能还是要劳师动众的给它建个工程写个插件,是不是很不爽?例如我有如下一个表单: 功能很简单就是选个业务对象,收集绑定几个字段名,然后确定返回一个 ...

  4. jquery GET POST

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <head> ...

  5. 使用spring的jdbcTemplate-----用JDBC模板查询数据库

    JdbcTemplate类声明了几个重载的query()模板方法来控制整个查询过程,就像进行更新数据操作一样,通过实现PreparedStatementCreator和PreparedStatemen ...

  6. 转:阿里开源Mysql分布式中间件:Cobar

    原文来自于:http://hualong.iteye.com/blog/2102798 这几天研究了下Cobar, Cobar是阿里巴巴研发的关系型数据的分布式处理系统(Amoeba的升级版,该产品成 ...

  7. DXP 技巧和龙芯3A装机

    时间过得好快!来公司已经半个月多了!本想着每日一搏,可是一再被耽搁,到今天才写.好了,废话不说了.就把自己这些天做的事写一些.理一理吧.也希望大家监督,由于水平有限,有不正确的地方,还望指正! 刚来做 ...

  8. Android模拟器常用命令收录

    一.Linux命令 1.挂载/systme分区为读写状态 mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system 2.切换为Root用户 ...

  9. [BZOJ 1218] [HNOI2003] 激光炸弹 【n logn 做法 - 扫描线 + 线段树】

    题目链接:BZOJ - 1218 题目分析 可以覆盖一个边长为 R 的正方形,但是不能包括边界,所以等价于一个边长为 R - 1 的正方形. 坐标范围 <= 5000 ,直接 n^2 的二维前缀 ...

  10. 安卓天天练练(五)CompoundButton

    ToggleButton 让我想起了从前jQuery还没有取消toggle方法时是怎么偷懒的.. 注意: 如果LinearLayout,与RelativeLayout不同,必须有orientation ...