我有一个由选项卡活动托管的活动。当我更改屏幕方向时,我的应用程序崩溃。
02-14 21:01:35.825: E/AndroidRuntime(9424): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testapp/com.example.testapp.MainActivity}
java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.AbsListView$SavedState
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2194)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2229)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3791)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.app.ActivityThread.access$700(ActivityThread.java:139)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.os.Handler.dispatchMessage(Handler.java:99)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.os.Looper.loop(Looper.java:154)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.app.ActivityThread.main(ActivityThread.java:4945)
02-14 21:01:35.825: E/AndroidRuntime(9424): at java.lang.reflect.Method.invokeNative(Native Method)
02-14 21:01:35.825: E/AndroidRuntime(9424): at java.lang.reflect.Method.invoke(Method.java:511)
02-14 21:01:35.825: E/AndroidRuntime(9424): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-14 21:01:35.825: E/AndroidRuntime(9424): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-14 21:01:35.825: E/AndroidRuntime(9424): at dalvik.system.NativeStart.main(Native Method)
02-14 21:01:35.825: E/AndroidRuntime(9424): Caused by: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.AbsListView$SavedState
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.widget.AbsListView.onRestoreInstanceState(AbsListView.java:1596)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.view.View.dispatchRestoreInstanceState(View.java:9977)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.view.ViewGroup.dispatchThawSelfOnly(ViewGroup.java:2346)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.widget.AdapterView.dispatchRestoreInstanceState(AdapterView.java:778)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2332)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2332)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2332)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2332)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2332)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2332)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2332)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2332)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2332)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.view.View.restoreHierarchyState(View.java:9955)
02-14 21:01:35.825: E/AndroidRuntime(9424): at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1671)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.app.Activity.onRestoreInstanceState(Activity.java:939)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.app.TabActivity.onRestoreInstanceState(TabActivity.java:84)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.app.Activity.performRestoreInstanceState(Activity.java:911)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1132)
02-14 21:01:35.825: E/AndroidRuntime(9424): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2172)
02-14 21:01:35.825: E/AndroidRuntime(9424): ... 12 more
清单中的这一行没有帮助:
android:configChanges="orientation|keyboardHidden"
还有一件事:在我的活动中,我使用来自https://github.com/dinocore1/DevsmartLib-Android的自定义视图(水平 ListView)
没有此自定义视图,该应用程序运行良好,但我需要使用它。