转载请注明出处: http://blog.csdn.net/user11223344abc?viewmode=contents 出自【蛟-blog】
存入
intent.putExtra("par","hello");取出
String str = data.getStringExtra("par");首先这个对象必须要序列化。
public class MachListBean implements Serializable{ ...... }传递前放入Intent:
Bundle bundle = new Bundle(); bundle.putSerializable("bean", mSelectBean); intent.putExtras(bundle);传递后从Intent内取出:
Bundle bundle = intent.getExtras(); selectBean = (MachListBean) bundle.getSerializable("bean");传递对象集合,首先这个对象必须要序列化。
public class OrderConfirmBean implements Serializable { ...... }传递前放入Intent:
//初始化集合 ocfList.add(OrderConfirmBean)... //放入Intent Intent intent = new Intent(mContext, OrderConfirmActivity.class); Bundle bundle = new Bundle(); bundle.putSerializable("list", (Serializable) ocfList); intent.putExtras(bundle); mContext.startActivity(intent);传递后从Intent内取出:
//this.list初始化 private List<OrderConfirmBean> list = new ArrayList<OrderConfirmBean>(); //从intent内取出 Bundle bundle = getIntent().getExtras(); Serializable list = null; if(null != bundle){ list = bundle.getSerializable("list"); if (null != list) { this.list = (List<OrderConfirmBean>) list; } }