Android之Intent对象
来源:互联网 发布:应届毕业生招聘软件 编辑:程序博客网 时间:2024/06/05 09:03
1.Intent对象的基本概念
Intent是Android应用程序组件之一
Intent对象在Android系统当中表示一种意图
Intent当中最重要的内容是action与data
2.使用Intent在Activity之间传递数据的方法
在activity之间可以通过Intent对象中传递数据
使用putExtra()系列向Intent对象当中存储数据
Intent是Android应用程序组件之一
Intent对象在Android系统当中表示一种意图
Intent当中最重要的内容是action与data
2.使用Intent在Activity之间传递数据的方法
在activity之间可以通过Intent对象中传递数据
使用putExtra()系列向Intent对象当中存储数据
使用getXXXExtra()系列方法从Intent对象中取出数据
<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=".MainActivity" > <Button android:id="@+id/button1" android:layout_height="wrap_content" android:layout_width="match_parent" android:text="启动第二个Activity"/></RelativeLayout>
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/text1" android:layout_width="match_parent" android:layout_height="wrap_content" /></LinearLayout>
package com.android.xiong.intent_one;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 button1;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);button1=(Button)findViewById(R.id.button1);OnClick on=new OnClick();button1.setOnClickListener(on);}class OnClick implements OnClickListener{@Overridepublic void onClick(View arg0) {// TODO Auto-generated method stubIntent intent =new Intent();intent.setClass(MainActivity.this, TwoActivity.class);String [] name={"zhangsan","lis","wangwu"};int []age={12,13,14};intent.putExtra("com.android.xiong.intent_one.Name", name);intent.putExtra("com.android.xiong.intent_one.Age", age);startActivity(intent);}}@Overridepublic 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;}}
package com.android.xiong.intent_one;import java.util.HashMap;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.widget.TextView;public class TwoActivity extends Activity{private TextView text1;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.activity_two);text1=(TextView)findViewById(R.id.text1);Intent intent=getIntent();String []name=intent.getStringArrayExtra("com.android.xiong.intent_one.Name");int [] age=intent.getIntArrayExtra("com.android.xiong.intent_one.Age");String print="";for (int i = 0; i < age.length; i++) {print+="name: "+name[i].toString()+" age: "+age[i]+" \n";}text1.setText(print);}}
- Android之Intent对象
- Android之Intent传对象
- Android开发之使用Intent传递对象
- Android 用Intent 传递对象之 Serializable
- Android 用Intent 传递对象之 Parcel
- android学习之intent对象传递类
- Android Intent传递对象
- Android Intent 传递对象
- Android Intent传递对象
- [Android] Intent 传递对象
- android Intent 传递对象
- Android Intent传递对象
- android intent传对象
- Android系列之Intent传递对象的两种方法
- Android Intent 之间传递对象之 Parcelable接口
- Android开发之如何使用Intent传递对象
- Android之使用 Intent 传递对象(一)Serializable 方式
- Android之使用 Intent 传递对象(一)Parcelable 方式
- 总结一下手动安装autoconf、automake和libtool的经历
- HTML5中File对象初探
- 【rmzt】动漫&&性感美女win7主题_8.13
- 一个在线免费设计icon的网址.
- 纯DIV+CSS圆角背景随按钮文字增多而增宽自适应,鼠标经过背景变化按钮型模块。
- Android之Intent对象
- STA区别MTA
- 学习c++的50条忠告(初学者必看)
- S3C6410 启动脚本
- WTL_代码使用 流程
- 网页色彩的搭配方法及原则
- DOS下创建、删除文件的几种方法
- java 加密解密源码
- Triangular numbers