Open aaearon opened 10 years ago
Same issue here. Except i'm not using fragments. I have a HeaderListView in one of my activities and i am now receiving this on GooglePlay every once in a while:
java.lang.RuntimeException: Unable to start activity ComponentInfo{se.creativecamp.android/*.BookActivity}: java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.widget.AbsListView$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/book_list. Make sure other views do not use the same id.
I believe i am using the latest version of HeaderListView.
I had the same issue, where I am using HeaderListView inside a fragment and my application crashes every time when switching between Landscape and Portrait Orientation. The solution by @aaearon has helped and now it is working using this line of code.
headerListView.getListView().setId(R.id.listMode);
The id here can be anything.
Another solution is to use tag instead of id.
Your layout file
<com.applidium.headerlistview.HeaderListView
android:tag="yourTag"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Your java file
HeaderListView yourListView = (HeaderListView) findViewWithTag("yourTag");
Same problem here when using DialogFragment. It also seem to appear only on specific devices. I cannot reproduce it on LG G4, but I can on Nexus 4 for example.
I think it can be fixed easily according to this StackOverflow post: http://stackoverflow.com/questions/24297279/wrong-state-class-expecting-view-state-but I don't have time for it currently, so if you can do it, please notify me :)
And this post is also related to this issue: http://stackoverflow.com/questions/25337592/android-id-clash-when-3-tabs-or-more-are-created
This stackoverflow post has more details and the workaround: http://stackoverflow.com/questions/25807332/crash-when-returning-to-fragment-as-a-tab-view-with-same-id
With two tabs (A & B fragment using HeaderListView), when switching from B to A back to B, the app crashes with
java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.widget.AbsListView$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/header_list_view. Make sure other views do not use the same id.
Other views are not using the same ID and to fix this issue I can
listview.setId()
inonCreateView
to anything.