我想保存视图“ArrayList”的ArrayList的内容。我重写方法“onSaveInstanceState”,如下面的代码所示,但在运行时我收到下面发布的logcat错误。 请让他们知道如何在捆绑中设置View对象列表
码:
@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)
答案 0 :(得分:0)
您不应该将视图保存在savedInstanceState中。你应该只保存listview的值。它将自动创建视图