android - How to store sparsearray in bundle -
i have sparsearray<myobject>
, want store in bundle in onsaveinstancestate
method in activity , restore in oncreate
. found putsparseparcelablearray
method set sparsearray in bundle , did in onsaveinstancestate
method:
bundle.putsparseparcelablearray("mysparsearray", mysparsearray);
but eclips shows error:
the method putsparseparcelablearray(string, sparsearray<? extends parcelable>) in type bundle not applicable arguments (string, sparsearray<myobject>)
and quick prepare casting argument mysparsarray
sparsearray<? extends parcelable>
, if , in oncreate method:
mysparsearray = (sparsearray<myobject>) savedinstancestate.getsparseparcelablearray("mysparsearray");
it gets error:
cannot cast sparsearray<parcelable> sparsearray<myobject>
if way wrong, solution set mysparsearray in bundle? help much appreciated.
your class should implement parcelable
, should have static final fellow member variable called creator
of type parcelable.creator<myobject>
.
android android-activity bundle sparse-array
No comments:
Post a Comment