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<
implement Parcelable
on the Product class as well and then
in.readList(this.list, Product.class.getClassLoader());
if any of the above solutions didn't work.
The other way is to use readValue&writeValue.
protected Product (Parcel in) {
...
in.readValue(this.getClass().getClassLoader());
}
@Override
public void writeToParcel(Parcel parcel, int i) {
...
parcel.writeValue(**list**);
}
Items of the list should implement Parcelable
Here you go...
Make sure "Products.java" should be extended with Parcelable
Step 1:
private List<Products> products;
Step 2:
private Outfits(Parcel in) {
products = in.createTypedArrayList(Products.CREATOR);
}
Step 3:
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeTypedList(products);
}