使用包含自定义动作的隐式Intent
来源:互联网 发布:新网域名转阿里云 编辑:程序博客网 时间:2024/05/21 06:59
1、activity_main.xml
<LinearLayout 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:orientation="vertical"> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="转到下一个Activity" android:textColor="@android:color/black"/></LinearLayout>
2、secondactivity_layout.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="第二个Activity" android:textColor="@android:color/black" android:textSize="25px" /></LinearLayout>
3、MainActivity.java
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button button = (Button)findViewById(R.id.button); button.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {Intent intent = new Intent();intent.setAction("");//为Intent设置动作startActivity(intent);}}); }}
public class SecondActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.secondactivity_layout);}}
5、AndroidManifest.xml配置文件,为两个Activity设置不同的Intent过滤器
<activity android:name="com.example.android6_3.MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".SecondActivity"> <intent-filter> <action android:name="<span style="font-family: Arial, Helvetica, sans-serif;">test_action</span>"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </activity>
0 0
- 使用包含自定义动作的隐式Intent
- 使用包含预定义动作的隐式Intent
- Intent 对象练习4---使用预定义动作的隐式Intent
- Android使用Intent实现拨打电话的动作
- Android通过Intent传输包含自定义类的ArrayList
- 通过Intent自定义动作、打开网页
- 常见的Intent跳转动作
- 显式intent和隐式intent的使用
- 显示Intent和隐式Intent的使用(意图)
- 显式Intent与隐式Intent的使用
- 自定义布局中包含组件的使用
- 监听本地广播的一些Intent动作
- 使用隐式的Intent启动activity
- 利用BEHAVIOR创建包含动作的CSS
- 自定义的intent
- 【转】Intent使用(包含两个activi…
- UserBean动作的使用
- Intent隐式启动自定义意图
- 扯淡
- Fragment详解之四——管理Fragment(2)
- 机器学习(五):Logistic回归
- UNIX网络编程——select函数的并发限制和 poll 函数应用举例
- 比较Python和Perl的效率
- 使用包含自定义动作的隐式Intent
- ssh服务
- Struts2 基于XML校验的一些特点
- Java串行程序并行化执行
- Fragment详解之五——Fragment间参数传递
- 一周总结
- C++ DirectX 游戏开发初级视频教程 05 资源下载链接
- 【php】error_reporting
- Windows下写shell脚本到Linux下执行遇到的问题及解决方案