我AbsListView
在几个片段和活动中使用 a,以便我可以ListView
在纵向模式和GridView
横向模式下使用 a。我在 ICS 和 JB 中进行了所有日常测试,而且效果很好。我开始在 GB 设备 (2.3.6) 上进行测试,当我在其中一个屏幕处于活动状态的情况下旋转设备时收到 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)