0
我在若干片段和活動中使用AbsListView
,因此我可以在縱向模式下使用ListView
,橫向中使用GridView
。我在ICS和JB上做了所有的日常測試,而且工作得很好。我開始在GB設備上進行測試(2.3.6),並且當我使用其中一個屏幕激活時旋轉設備時出現ClassCastException。以下是堆棧跟蹤:AbsListView:屏幕方向更改期間的onRestoreInstanceState中的ClassCastException
05-09 14:04:55.019: E/AndroidRuntime(6052): Caused by: java.lang.ClassCastException: android.widget.ListView$SavedState
05-09 14:04:55.019: E/AndroidRuntime(6052): at android.widget.AbsListView.onRestoreInstanceState(AbsListView.java:1018)
05-09 14:04:55.019: E/AndroidRuntime(6052): at android.view.View.dispatchRestoreInstanceState(View.java:6325)
05-09 14:04:55.019: E/AndroidRuntime(6052): at android.view.ViewGroup.dispatchThawSelfOnly(ViewGroup.java:1314)
05-09 14:04:55.019: E/AndroidRuntime(6052): at android.widget.AdapterView.dispatchRestoreInstanceState(AdapterView.java:767)
05-09 14:04:55.019: E/AndroidRuntime(6052): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1301)
05-09 14:04:55.019: E/AndroidRuntime(6052): at android.view.View.restoreHierarchyState(View.java:6304)
05-09 14:04:55.019: E/AndroidRuntime(6052): at android.support.v4.app.Fragment.restoreViewState(Fragment.java:417)