oop - Extending an Android Parcelable class -
i have customaddress
class extends android.location.address
class implements parcelable
.
i trying make customaddress
implement parcelable
to stuck when creating class parcel. want when creating customaddress
from parcel first fill in fields super class address
and own fields. have implemented creator
field:
public static final parcelable.creator<customaddress> creator = new parcelable.creator<customaddress>() { public customaddress createfromparcel(parcel in) { return new customaddress(in); } public customaddress[] newarray(int size) { return new customaddress[size]; } };
but in customaddress(parcel in)
creator, can't call super(in)
because doesn't exist in android.location.address
. can access android.location.address.creator
. how fill in fields using creator
?
edit: link android address
class https://developer.android.com/reference/android/location/address.html
here similar question , mark murphy's excellent answer: https://stackoverflow.com/a/10841502/1140682
so, in case, make customaddress
extend address
(as do), call super()
method in constructor , read own attributes passed parcel
. same has done (in same order) in writetoparcel()
method, of course here adding attributes parcel.
Comments
Post a Comment