Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when returning to fragment as a tab. View with same id #28

Open
aaearon opened this issue Oct 15, 2014 · 5 comments
Open

Crash when returning to fragment as a tab. View with same id #28

aaearon opened this issue Oct 15, 2014 · 5 comments
Labels

Comments

@aaearon
Copy link

aaearon commented Oct 15, 2014

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() in onCreateView to anything.

@Slangen
Copy link

Slangen commented Oct 20, 2014

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.

@oarshad
Copy link

oarshad commented Oct 20, 2014

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.

@tokou tokou added the bug label Jan 23, 2015
@mauriciogior
Copy link

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");

@bendaf
Copy link

bendaf commented Mar 31, 2016

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

@bendaf
Copy link

bendaf commented Mar 31, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants