Bundle传递集合对象

1.将对象定义成 Parcelable 类型

class 类名 implements Parcelable{ }


  1. Bundle b = new Bundle();  
  2. b.putParcelableArrayList("list",集合对象);  
  3. 接收:
  4. ArrayList<类名> temp = b.getParcelableArrayList("list");  


2.将对象定义成 Serializable 类型

class 类名 implements Serializable{ }

  1. Bundle b = new Bundle();  
  2. b.putSerializable("list", 集合对象);
  3. 接收:
  4. ArrayList<类名> temp = (ArrayList<类名>) b.getSerializable("list");  
注意:
传递的集合是ArrayList<>

你可能感兴趣的:(API的使用)