I have an ArrayList
from my class. I'm trying to pass it through Parcelable
, but get an error.
Below is the structure of the class and the code itself. How can I pass this type of data?
Class
class Lists{
String name_opt;
byte[] value;
}
class ConfigStruct{
String page;
String name;
String type;
byte[] val_size;
byte[] max_lenght;
byte[] min_lenght;
byte[] value;
List<Lists> list;
View view;
}
ConfigStructParcelable
public class ConfigStructParcelable implements Parcelable {
List<Tabs.ConfigStruct> structs;
public ConfigStructParcelable(ArrayList<Tabs.ConfigStruct> data){
this.structs = data;
}
public ConfigStructParcelable(Parcel in){
this.structs = in.readArrayList(null);//?
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeList(structs); //?
}
public static Creator<ConfigStructParcelable> CREATOR = new Creator<ConfigStructParcelable>() {
@Override
public ConfigStructParcelable createFromParcel(Parcel source) {
return new ConfigStructParcelable(source);
}
@Override
public ConfigStructParcelable[] newArray(int size) {
return new ConfigStructParcelable[size];
}
};
}
I have marked two spots "//?" to understand how to properly write to the parcel and how to reconstruct it.
Post by link didn't help.
how to properly implement Parcelable with an ArrayList<Parcelable>?