android parcelable对象中有集合怎么写
请看例子:
public class Bill implements Parcelable {
public int staff;
public int type;
public Goods goods[];
public List<Goods> arrgoods;
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(staff);
dest.writeInt(type);
dest.writeParcelableArray(goods, flags);
}
@SuppressWarnings("unused")
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
@Override
public Bill createFromParcel(Parcel in) {
return new Bill(in);
}
@Override
public Bill[] newArray(int size) {
return new Bill[size];
}
};
}
顺便推荐一款学习android的利器:
android学习手册,里面有源码。android学习手册包含9个章节,108个例子,源码文档随便看,例子都是可交互,可运行,源码采用android studio目录结构,高亮显示代码,文档都采用文档结构图显示,可以快速定位。360手机助手中下载,图标上有贝壳: