Unexplainable ClassCastException in android.widget.ProgressBar.onRestoreInstanceState

后端 未结 7 1665
予麋鹿
予麋鹿 2020-12-29 19:21

I\'ve had my application out in the store for a while, but it seems it crashes occasionally according to the crash reports in the Developer Console, saying: java.lang.

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-29 19:32

    In my case my portrait xml has Relativelayout and ScrollView from landscape xml with the same ID.

    On my activity class I try to inflate the layout and assign it on ViewGroup

    So when screen rotation occur it throws: java.lang.ClassCastException: android.view.AbsSavedState$1 cannot be cast to android.widget.ScrollView$SavedState

    It's because the ScrollView extends FrameLayout while Relativelayout extends ViewGroup

    So i just wrap the landscape xml with Relativelayout and solves the problem

提交回复
热议问题