我最近开始在我们的生产应用程序中遇到以下异常。
{“androidApiLevel”:“28”,“osBuild”:“PQ2A.190405.003”}
设备:Pixel 2 XL
你知道这是怎么回事吗?
java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.ScrollView$SavedState
at android.widget.ScrollView.onRestoreInstanceState(ScrollView.java:1834)
at android.view.View.dispatchRestoreInstanceState(View.java:18608)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3821)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3827)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3827)
at android.view.View.restoreHierarchyState(View.java:18586)
at androidx.e.a.d.restoreViewState(Fragment.java:494)
at androidx.e.a.j.a(FragmentManager.java:1486)
at androidx.e.a.j.f(FragmentManager.java:1784)
at androidx.e.a.j.a(FragmentManager.java:1852)
at androidx.e.a.j.e(FragmentManager.java:3269)
at androidx.e.a.j.q(FragmentManager.java:3229)
at androidx.e.a.g.f(FragmentController.java:201)
at androidx.e.a.e.onStart(FragmentActivity.java:620)
at androidx.appcompat.app.d.onStart(AppCompatActivity.java:178)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1391)
at android.app.Activity.performStart(Activity.java:7165)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:2975)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Method.java:-2)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2条答案
按热度按时间kninwzqo1#
可能会有这样的情况,即您对两个元素使用相同的ID名称。
用其他视图重新检查分配给该滚动视图的ID
kkbh8khc2#
我通过遍历滚动视图的子视图并以编程方式为它们分配id来解决这个问题:
您可以使用
getChildCount()
和getChildAt()
等来迭代它们。