1

当我启动我的应用程序时,我遇到的异常只有大约 5-10% 的时间发生。该活动主要包含ScrollView垂直排列的大约20张“卡片”(如列表)。每个“卡片”都是Fragment我简单地构建 20 次并添加LinearLayoutScrollView.

当我启动它时,我的应用程序有时会立即崩溃......

07-25 11:14:04.211: E/AndroidRuntime(21490): Caused by: java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.widget.ProgressBar$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/home_page_category_image. Make sure other views do not use the same id.
07-25 11:14:04.211: E/AndroidRuntime(21490):    at android.view.View.onRestoreInstanceState(View.java:9990)
07-25 11:14:04.211: E/AndroidRuntime(21490):    at android.view.View.dispatchRestoreInstanceState(View.java:9966)
07-25 11:14:04.211: E/AndroidRuntime(21490):    at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2622)
07-25 11:14:04.211: E/AndroidRuntime(21490):    at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2628)
07-25 11:14:04.211: E/AndroidRuntime(21490):    at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2628)
07-25 11:14:04.211: E/AndroidRuntime(21490):    at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2628)
07-25 11:14:04.211: E/AndroidRuntime(21490):    at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2628)
07-25 11:14:04.211: E/AndroidRuntime(21490):    at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2628)
07-25 11:14:04.211: E/AndroidRuntime(21490):    at android.view.View.restoreHierarchyState(View.java:9944)
07-25 11:14:04.211: E/AndroidRuntime(21490):    at android.app.Fragment.restoreViewState(Fragment.java:685)
07-25 11:14:04.211: E/AndroidRuntime(21490):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:855)
07-25 11:14:04.211: E/AndroidRuntime(21490):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1034)
07-25 11:14:04.211: E/AndroidRuntime(21490):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1016)
07-25 11:14:04.211: E/AndroidRuntime(21490):    at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1768)
07-25 11:14:04.211: E/AndroidRuntime(21490):    at android.app.Activity.performCreate(Activity.java:4546)
07-25 11:14:04.211: E/AndroidRuntime(21490):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
07-25 11:14:04.211: E/AndroidRuntime(21490):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2181)
07-25 11:14:04.211: E/AndroidRuntime(21490):    ... 11 more

确实,View每个“卡片”中的一个 s 都有一个 id 标签home_page_category_image。我环顾四周,大多数人遇到此错误通常与方向更改有关。我在 manifest 中指定了这个活动只能处于竖屏状态。此外,更奇怪的是,这个异常只发生在 5-10% 的时间里。

有谁知道这可能是什么原因或如何解决?

4

0 回答 0