i want to save the contents of an ArrayList of Views "ArrayList". i overriden the method "onSaveInstanceState" as shown below in the code, but at run time i receive the below posted logcat errors . please let em know how to set a list of View objects in a bundle
code:
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Log.w(TAG, "onSaveInstanceState");
if (this.mListViews != null && this.mListViews.size() > 0) {
outState.putSerializable(KEY_LIST_OF_VIEWS, this.mListViews);
}
}
logcat
java.lang.RuntimeException: Parcel: unable to marshal value android.widget.ImageView{8787bd0 V.ED..... ........ 20,20-1580,2247}
at android.os.Parcel.writeValue(Parcel.java:1419)
at android.os.Parcel.writeList(Parcel.java:760)
at android.os.Parcel.writeValue(Parcel.java:1366)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:687)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330)
at android.os.Bundle.writeToParcel(Bundle.java:1079)
at android.os.Parcel.writeBundle(Parcel.java:712)
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3753)
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:4704)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7331)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
you should not save the view in savedInstanceState. you should only save the value of the listview. it view will be created automatically