I have created a Parcelable object below, my object contains a List of Products. In my constructor how do I handle re-creating my Parcelable<
Product must be implements Parcelable
Product class implements Parcelable {
......
}
Then write you object contains list like
public class Outfits implements Parcelable {
private String url;
private String name;
private List products;
public Outfits (Parcel pi) {
bookName = p.readString();
bookId = p.readInt();
isColor = p.readInt() == 1;
//use this well be get err
//products=p.readArrayList(Thread.currentThread().getContextClassLoader());
//Pass list use this
products= in.createTypedArrayList(Product.CREATOR);
}
...get and set...
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(url);
dest.writeString(name);
//use this will no working
//dest.writeList(products);
//Parcelable list
out.writeTypedList(products);
}
}