eg. 传递 ArrayList<Group> groups
一:将对象定义成 Parcelable 类型
public class Group implements Parcelable{ }
in:
Bundle b = new Bundle(); b.putParcelableArrayList("list",groups);
out:
ArrayList<Group> groups = b.getParcelableArrayList("list");
二,将对象定义成 Serializable 类型
public class Group implements Serializable{ }
in:
Bundle b = new Bundle(); b.putSerializable("list", groups);
out:
ArrayList<Group> groups = (ArrayList<Group>) b.getSerializable("list");
时间: 2024-10-14 06:47:37