I'm trying to make my class parcelable, but it has a list of enums inside.
I've already seen how to do this with single enums here...
How could I do this?
Thanks! ;)
Ok, I solved this just using the information at the link cited before.
That was what I did:
public enum Improvement {ENUM1, ENUM2, etc}
public void writeToParcel(Parcel dest, int flags) {
...
List<String> improvementStrings = new ArrayList<String>();
for (Improvement improvement : improvements) {
improvementStrings.add(improvement.name());
}
dest.writeList(improvementStrings);
}
public void readFromParcel(Parcel in) {
...
List<String> improvementStrings = new ArrayList<String>();
in.readList(improvementStrings, null);
for (String improvementString : improvementStrings) {
improvements.add(Improvement.valueOf(improvementString));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With