Skip to content Skip to sidebar Skip to footer

How To Use Parcelable On Non-primitive Types?

I have a class TableMetaAttrs: public class TableMetaAttrs implements Parcelable { private Integer id; private String name; private String value; private Tables tab

Solution 1:

You have to make the Tables class implements Parcelable as well.

That way whenever TableMetaAttrs is parcelling or re-building itself, it can call putParcelable and getParcelable for the table field.

edit:

I'm assuming Tables is a class you created, so it's signature must be

publicclassTablesimplementsParcelable{
    // and somewhere in this code tables have to parcel all it's primitives
}

then whenever TableMetaAttrs is parcelling it's values it calls:

 parcel.putParcelable(table);

and rebuilding it:

table = parcel.getParcelable();

Post a Comment for "How To Use Parcelable On Non-primitive Types?"