一 前言
Fragment学习(一)中学习了怎么传递基本数据类型和String。但是对于我们自定义的数据类型来说,应该怎么传递呢?
有两种方式,第一种是实现Parcelable
接口,第二种是实现Serializable
接口
Serializable
接口的实现据说非常的简单,只需要声明一下即可。
但是Parcelable
接口的序列化效率要高于Serializable接口。
考虑到我自己要传递一个比较大的ArrayList,我决定学习一下Parcelable
参考资料:
android开发之Parcelable使用详解
Android中的Parcelable详解
Activity传递对象集合到Fragment
二 实践
说是困难,其实并不。
2.1 bean类实现Parcelable
把bean类 implements Parcelable
之后,IDE会出现一