android应用开发详解(十四)----------------Intent的Category属性(续)
2014-10-09 20:49
621 查看
1、工程目录
![](http://img.blog.csdn.net/20141009204827546?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaHVsYW5fYmFieQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
2、MainActivity.java
main.xml
4、结果演示
![](http://img.blog.csdn.net/20141009205158840?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaHVsYW5fYmFieQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
2、MainActivity.java
package com.example.test_intent_category; 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; import android.widget.Button; public class MainActivity extends Activity { private Button myBtn; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); myBtn = (Button) findViewById(R.id.button01); myBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub Intent intent = new Intent(); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); startActivity(intent); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } }3、布局文件
main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <Button android:id="@+id/button01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="回到Home" /> </LinearLayout>
4、结果演示
相关文章推荐
- android应用开发详解(十四)------------------Intent的ComponentName属性
- android应用开发详解(十四)--------------Intent的Action属性(续)
- android应用开发详解(十四)-------------Intent的Extras属性(续)
- android应用开发详解(十四)------------------------action属性(续)
- Android 程式开发:(四)使用Intent调用“内置”应用 —— 4.4添加Category属性
- Android开发学习笔记:Intent的简介以及属性的详解
- Android开发--Intent-filter属性详解
- Android开发学习笔记:Intent的简介以及属性的详解
- Android开发--Intent-filter属性详解
- Android开发--Intent-filter属性详解
- Android开发--Intent-filter属性详解
- Android开发–Intent-filter属性详解
- android应用开发之intent详解
- Android开发--Intent-filter属性详解
- Intent的Component,Action和Category属性详解-android学习之旅(五十)
- Android开发--Intent-filter属性详解
- Android开发--Intent-filter属性详解
- Android开发-——-Intent-filter属性详解
- Android开发--Intent-filter属性详解
- Android开发————Intent中的四个重要属性Action、Data、Category、Extras