2 u012591487 u012591487 于 2016.02.19 20:31 提问

用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)

3个回答

devmiao
devmiao   Ds   Rxr 2016.02.19 22:10
已采纳
liuguangsuiyue
liuguangsuiyue   2016.02.19 23:03

java.lang.ClassCastException: com.viewpagerindicator.CirclePageIndicator$SavedState cannot be cast to android.widget.HorizontalScrollView

是你在XML种布局的使用类型不一致吧, 仔细查看下。 强制转换必须是子类转父类才可以比如: List list = new ArrayList(); View v = findViewById(id); 或者是该类实现了同样的借口等

luochoudan
luochoudan   Ds   Rxr 2016.02.19 22:25

java.lang.ClassCastException: com.viewpagerindicator.CirclePageIndicator$SavedState cannot be cast to android.widget.HorizontalScrollView$SavedState,类型异常,从这往回找吧

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!