Intent对象练习1---返回系统桌面
来源:互联网 发布:mac怎么玩守望先锋 编辑:程序博客网 时间:2024/06/09 15:45
代码:
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/home_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="返回Home" android:textColor="@android:color/black"/></LinearLayout>
MainActivity.java
package com.example.intentone;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button home=(Button) findViewById(R.id.home_button); home.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubIntent intent=new Intent();intent.setAction(Intent.ACTION_MAIN);//设置Intent动作intent.addCategory(Intent.CATEGORY_HOME);//设置Intent种类startActivity(intent);}}); }}
截图:
0 0
- Intent对象练习1---返回系统桌面
- 通过Intent实现返回桌面
- 迅速返回系统桌面
- 返回系统HOME桌面
- 返回系统Home桌面
- 5 返回桌面 Intent的action 和 category 属性
- Intent对象练习2---使用Intent拨打电话
- Intent对象练习3---使用Intent打开网页
- Android intent 传递对象以及返回刷新
- C++,返回对象的引用,语法练习
- 返回桌面
- 返回桌面
- 调用系统相机拍照返回Intent 为空的处理。
- Android调用系统照相机返回intent为空原因分析
- Intent 对象练习4---使用预定义动作的隐式Intent
- Intent 对象
- Intent对象
- Intent对象
- 杭州最全登山路线图
- MyEclipse使用Maven
- Python 学习笔记 多进程 multiprocessing
- [Debug之路]MFC遇到的问题记录
- scala.Predef
- Intent对象练习1---返回系统桌面
- 详解Linux bash变量
- svn安装脚本
- Java:String 字符串的替换函数 replace replaceAll replaceFirst
- 快速排序-递归与分治
- cocos ,cocos studio ,cocos creater的简单介绍
- dbms_transaction包
- Spring MVC和Struts2的比较
- 稳定性治理