gpt4 book ai didi

view - Tabhost with view pager, ClassCast 错误

转载 作者:行者123 更新时间:2023-12-05 01:36:59 26 4
gpt4 key购买 nike

我有一个事件,它为一周中的每一天填充一个 ScrollView ,并使用 View 寻呼机在操作栏上制作的选项卡上显示它们。每当我返回到我已经访问过的选项卡时,我都会收到一个类转换错误。这是我的日志猫。谁能告诉我为什么会导致这个异常。

08-23 05:01:50.589: E/AndroidRuntime(3836): FATAL EXCEPTION: main

08-23 05:01:50.589:E/AndroidRuntime(3836):java.lang.ClassCastException:android.view.AbsSavedState$1 cannot be cast to android.widget.CompoundButton$SavedState
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.widget.CompoundButton.onRestoreInstanceState(CompoundButton.java:379)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.view.View.dispatchRestoreInstanceState(View.java:12284)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2626)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2626)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2626)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2626)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2626)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.view.View.restoreHierarchyState(View.java:12262)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.support.v4.app.Fragment.restoreViewState(Fragment.java:425)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:949)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1460)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:472)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:163)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.support.v4.view.ViewPager.populate(ViewPager.java:1068)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:550)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:509)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:490)
08-23 05:01:50.589: E/AndroidRuntime(3836): at com.example.attendogram.Start.onTabSelected(Start.java:195)
08-23 05:01:50.589: E/AndroidRuntime(3836): at com.android.internal.app.ActionBarImpl.selectTab(ActionBarImpl.java:572)
08-23 05:01:50.589: E/AndroidRuntime(3836): at com.android.internal.app.ActionBarImpl$TabImpl.select(ActionBarImpl.java:1098)
08-23 05:01:50.589: E/AndroidRuntime(3836): at com.android.internal.widget.ScrollingTabContainerView$TabClickListener.onClick(ScrollingTabContainerView.java:547)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.view.View.performClick(View.java:4240)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.view.View$PerformClick.run(View.java:17721)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.os.Handler.handleCallback(Handler.java:730)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.os.Handler.dispatchMessage(Handler.java:92)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.os.Looper.loop(Looper.java:137)
08-23 05:01:50.589: E/AndroidRuntime(3836): at android.app.ActivityThread.main(ActivityThread.java:5103)
08-23 05:01:50.589: E/AndroidRuntime(3836): at java.lang.reflect.Method.invokeNative(Native Method)
08-23 05:01:50.589: E/AndroidRuntime(3836): at java.lang.reflect.Method.invoke(Method.java:525)
08-23 05:01:50.589: E/AndroidRuntime(3836): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-23 05:01:50.589: E/AndroidRuntime(3836): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-23 05:01:50.589: E/AndroidRuntime(3836): at dalvik.system.NativeStart.main(Native Method)

最佳答案

我遇到了类似的问题。在寻找答案时,我偶然发现了这篇文章。 Unexplainable ClassCastException in android.widget.ProgressBar.onRestoreInstanceState

在我们所有的案例中,android.view.AbsSavedState$1 都被转换为其他组件。

接受的答案说问题是应用程序正在重用 ID。

“仔细检查您的应用程序是否在两个不同的地方重复使用相同的 ID”

如果您使用的是 eclipse,Lint 工具可以帮助追踪重复的 ID。 enter image description here .我希望这有帮助。

关于view - Tabhost with view pager, ClassCast 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25462618/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com