方法一: 
如果单纯的传递List<String> 或者List<Integer>的话 就可以直接使用

Java代码

intent.putStringArrayListExtra(name, value)

intent.putIntegerArrayListExtra(name, value)

方法二: 
如果传递的是List<Object>,可以把list强转成Serializable类型,然后通过 
Java代码  putExtras(key, (Serializable)list)  
方法传递过去,接受的时候用 
Java代码  (List<YourObject>) getIntent().getSerializable(key)  
就可以接受到List<YourObject>数据了

但是 切记 你的YourObject类必须要实现Serializable接口

方法三: 
一种是 
Java代码  Bundle.putSerializable(Key,Object);  
另一种是 
Java代码  Bundle.putParcelable(Key, Object);  
当然这些Object是有一定的条件的,前者是实现了Serializable接口,而后者是实现了Parcelable接口

方法四: 
用intent传来传去 觉得不方便 我们可以写一个在application里面的全局数据

1、创建一个属于你自己的android.app.Application的子类 
2、在manifest中申明一下这个类, 
3、这时android就为此建立一个全局可用的实例,你可以在其他任何地方使用Context.getApplicationContext()方法获取这个实例,进而获取其中的状态(变量)。

继承Application 
Java代码

class MyApp extends Application {

private String myState;

public String getState(){

return myState;

}

public void setState(String s){

myState = s;

}

}

关于AndroidManifest.xml中的配置,原来直接给application加个name就可以了,如下面所示: 
Java代码  <application android:name=".MyApp"           android:icon="@drawable/icon"  android:label="@string/app_name">

使用 
Java代码

class Blah extends Activity {

@Override

public void onCreate(Bundle b){

...

MyApp appState = ((MyApp)getApplicationContext());

String state = appState.getState();

...

}

}

***此为转载,不过感觉自己比较常用利于参开放在这里:http://hi.baidu.com/ihsauqaxblbdmwq/item/dfc9cf9c352b0bdf1a49dfd5

        Intent intent = new Intent(this, ThirdActivity.class);
Person p = new Person();
p.setId(1);
p.setName("驰哥");
p.setSalary(456.1);
Person p2 = new Person();
p2.setId(2);
p2.setName("魏神");
p2.setSalary(111.111); List<Person> list = new ArrayList<Person>();
list.add(p);
list.add(p2);
Bundle extras = new Bundle();
extras.putSerializable("list", (Serializable) list);
intent.putExtras(extras);
startActivity(intent);
     Bundle ex = intent.getExtras();
List<Person> p = (List<Person>) ex.getSerializable("list");
Toast.makeText(this, p.toString(), Toast.LENGTH_SHORT).show();

Android intent传递list或对象的更多相关文章

  1. android intent 传递list或者对象

    (转:http://www.cnblogs.com/lee0oo0/archive/2012/09/24/2699805.html) 方法一: 如果单纯的传递List<String> 或者 ...

  2. Android Intent传递数据

    刚开始看郭大神的<>,实现以下里面的一些例子.Intent传递数据. 我们利用显示的方式进行Intent的启动. 1.启动intent并输入数据. Intent intent=new In ...

  3. Android Intent传递对象小结

    效果: 想看实例的,感兴趣的能够看之前的一篇文章 Android ViewPager Fragment实现选项卡 部分关键代码: public class SerializeActivity exte ...

  4. Android Intent传递对象摘要

    效果: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaG9uZ3NoZW5ncGVuZw==/font/5a6L5L2T/fontsize/400/fil ...

  5. Android Intent 基本使用及对象构成

    Intent基本使用 Intent可以理解为不同组件通信的媒介或者信使. Intent可以启动一个Activity,也可以启动一个Service,还可以发起一个广播Broadcast. 具体方法如下表 ...

  6. Android:Intent传递数据的几种类型和源码实现

    public class Intent implements Parcelable, Cloneable {   //... private String mAction; private Uri m ...

  7. android activity传递实体类对象

    通过实现Parcelable接口序列化对象的步骤: 1.实现Parcelable接口.2.并且实现Parcelable接口的public void writeToParcel(Parcel dest, ...

  8. Android Intent 传递数据注意事项

    不要通过 Intent 在 Android 基础组件之间传递大数据(binder transaction缓存为 1MB),可能导致 OOM.

  9. android intent 传递 二进制数据

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha 实现序列化.

随机推荐

  1. CSS3实现气泡效果

    首先定义一个 <p class="speech"></p> 先给外层的容器添加样式: p.speech { position: relative; widt ...

  2. [Editor]Unity Editor类常用方法

    Editor文档资料 Unity教程之-Unity Attribute的使用总结:http://www.unity.5helpyou.com/3550.html 利用unity3d属性来设置Inspe ...

  3. JMeter学习(十八)JMeter测试Java(二)

    实例: 服务为:将输入的两个参数通过IO存入文件: 1.打开MyEclipse,编写Java代码 服务: package test; import java.io.File; import java. ...

  4. 常用Eclipse插件在线安装地址

    Srping IDE http://www.springsource.com/update/e3.5   EasyShellhttp://pluginbox.sourceforge.net   M2E ...

  5. IE插件收集

    IEWatch IEWatch是一个微软IE的内置插件,可以让你看到和分析HTTP/HTTPS头信息,Cookies以及通过GET和POST提交的数据.我是经常用来看页面加载时间 下载最新版本请访问: ...

  6. [转] Android实时抓包分析 : 善用adb调试桥

    Android实时抓包分析 : 善用adb调试桥   谈到android网络抓包,很多人都能想到牛逼轰轰的神器tcpdump.方法就是在android机器上面安装tcpdump,然后通过-w参数把抓包 ...

  7. smarty模板继承

  8. 10Mybatis_mybatis和hibernate本质区别和应用场景

    hibernate:是一个标准的ORM框架(对象关系映射).入门门槛较高,不需要程序写sql语句,sql语句自动生产了. 对sql的优化比较困难. 应用场景:适用与需求变化不多的中小型项目中,比如后台 ...

  9. 第五章 使用 Bootstrap Typeahead 组件(百度下拉效果)

    推荐链接:http://www.cnblogs.com/haogj/p/3376874.html UnderScore官网:http://underscorejs.org/ 参考文档:http://w ...

  10. SQL2008安装后激活方式以及提示评估期已过解决方法(转)

    第一步:进入SQL2008配置工具中的安装中心第二步:再进入维护界面,选择版本升级第三步:进入产品密钥,输入密钥第四步:一直点下一步,直到升级完毕.SQL Server 2008 Developer: ...