问题描述
- 用android viewPager出现的强转异常
-
用一个页面切换到另外一个页面出现了异常
02-19 19:56:32.645: E/GED(11205): Failed to get GED Log Buf, err(0)
02-19 19:56:37.141: E/AndroidRuntime(11205): FATAL EXCEPTION: main
02-19 19:56:37.141: E/AndroidRuntime(11205): Process: com.example.shuyannvshen, PID: 11205
02-19 19:56:37.141: E/AndroidRuntime(11205): java.lang.ClassCastException: com.viewpagerindicator.CirclePageIndicator$SavedState cannot be cast to android.widget.HorizontalScrollView$SavedState
02-19 19:56:37.141: E/AndroidRuntime(11205): at android.widget.HorizontalScrollView.onRestoreInstanceState(HorizontalScrollView.java:1667)
02-19 19:56:37.141: E/AndroidRuntime(11205): at android.view.View.dispatchRestoreInstanceState(View.java:14030)
02-19 19:56:37.141: E/AndroidRuntime(11205): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3018)
02-19 19:56:37.141: E/AndroidRuntime(11205): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3024)
02-19 19:56:37.141: E/AndroidRuntime(11205): at android.view.View.restoreHierarchyState(View.java:14008)
02-19 19:56:37.141: E/AndroidRuntime(11205): at android.support.v4.app.Fragment.restoreViewState(Fragment.java:449)
02-19 19:56:37.141: E/AndroidRuntime(11205): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:964)
02-19 19:56:37.141: E/AndroidRuntime(11205): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1121)
02-19 19:56:37.141: E/AndroidRuntime(11205): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
02-19 19:56:37.141: E/AndroidRuntime(11205): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1484)
02-19 19:56:37.141: E/AndroidRuntime(11205): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:450)
02-19 19:56:37.141: E/AndroidRuntime(11205): at android.os.Handler.handleCallback(Handler.java:815)
02-19 19:56:37.141: E/AndroidRuntime(11205): at android.os.Handler.dispatchMessage(Handler.java:104)
02-19 19:56:37.141: E/AndroidRuntime(11205): at android.os.Looper.loop(Looper.java:194)
02-19 19:56:37.141: E/AndroidRuntime(11205): at android.app.ActivityThread.main(ActivityThread.java:5691)
02-19 19:56:37.141: E/AndroidRuntime(11205): at java.lang.reflect.Method.invoke(Native Method)
02-19 19:56:37.141: E/AndroidRuntime(11205): at java.lang.reflect.Method.invoke(Method.java:372)
02-19 19:56:37.141: E/AndroidRuntime(11205): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
02-19 19:56:37.141: E/AndroidRuntime(11205): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
解决方案
解决方案二:
java.lang.ClassCastException: com.viewpagerindicator.CirclePageIndicator$SavedState cannot be cast to android.widget.HorizontalScrollView
是你在XML种布局的使用类型不一致吧, 仔细查看下。 强制转换必须是子类转父类才可以比如: List list = new ArrayList(); View v = findViewById(id); 或者是该类实现了同样的借口等
解决方案三:
java.lang.ClassCastException: com.viewpagerindicator.CirclePageIndicator$SavedState cannot be cast to android.widget.HorizontalScrollView$SavedState,类型异常,从这往回找吧
时间: 2024-11-10 07:48:22