Android Intent传递对象和ArrayList【大明进化十八】
以前做项目的时候,需要Intent 传递复杂类型,例如:数组,ArrayList类型,传递类对象,今天抽空写了个例子,方便以后用的时候查询!有问题可以留言;
转载请标明出处:
http://blog.csdn.net/wdaming1986/article/details/6762633
程序主界面: 点击list按钮传递数据:
点击parcelable传递数据: 点击serializable传递数据:
下面看代码:
一、MainAcitivty。java类的代码:
<span style="font-size:16px;color:#000000;">package com.cn.daming;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.GradientDrawable.Orientation;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity implements Serializable{
private static final long serialVersionUID = 1L;
private String s_name;
private int s_number;
private String s_易做图;
private Button list_Button;
private Button ser_Button;
private Button par_Button;
private ArrayList<String> m_list;
public final static String PAR_KEY = "com.cn.daming.parcelable";
public final static String SER_KEY = "com.cn.daming.serializable";
public final static String LIST_KEY = "com.cn.daming.ArrayList";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initlist();
drawBackground();
initList_Button();
initPar_Button();
inintSer_Button();
}
public void initlist()
{
m_list = new ArrayList<String>();
m_list.add("大明ArrayList");
m_list.add("年龄:25岁");
m_list.add("性别:男");
补充:移动开发 , Android ,