Open MrVilkaman opened 8 years ago
I encountered the same problem yesterday. While this may be a bug in the library, why do you need to set the adapter again? I assume the setAdapter()
call in is onResume
... why not in onCreate
?
@justincpollard I do it in onCreateView
. When I was come back from another fragment, I have new instance of RecyclerViewPager
but old instance of adapter
Aw, I see. Well you could just create a new adapter to back the new RecyclerViewPager, right? If you're loading something from network maybe you could do that in onCreate, then simply set those items on the new adapter in onCreateView?
@justincpollard I can do so, but my approach is works in the usual RecyclerView.
I will check it ~~~ Thx for your issue!
I'm experiencing the same issue, any luck ?
java.lang.IllegalStateException: Cannot change whether this adapter has stable IDs while the adapter has registered observers.
at android.support.v7.widget.RecyclerView$Adapter.setHasStableIds(RecyclerView.java:5535)
at com.lsjwzh.widget.recyclerviewpager.RecyclerViewPagerAdapter.setHasStableIds(RecyclerViewPagerAdapter.java:57)
at com.lsjwzh.widget.recyclerviewpager.RecyclerViewPagerAdapter.
Also having the same problem. I'm currently using Android Annotations to inject the adapter so i can't really control it's lifecycle.
What if we replace ensureRecyclerViewPagerAdapter(...) function
@SuppressWarnings("unchecked")
@NonNull
protected RecyclerViewPagerAdapter ensureRecyclerViewPagerAdapter(Adapter adapter) {
return (adapter instanceof RecyclerViewPagerAdapter)
? (RecyclerViewPagerAdapter) adapter
: new RecyclerViewPagerAdapter(this, adapter);
}
with
@SuppressWarnings("unchecked")
@NonNull
protected RecyclerViewPagerAdapter ensureRecyclerViewPagerAdapter(Adapter adapter) {
return new RecyclerViewPagerAdapter(this, adapter);
}
I think it will create new Adapter every time.
Getting the same issues when using the RecyclerViewPager as a nested horizontal row within a traditional vertical RecyclerView, when it goes through and rebinds the row, it hits this issue.
Any solutions on this issue?
Facing the same issue when extending a class with recyclerviewpager, that was previously extending a regular recyclerview. Any updates?
I got a workaround that did the trick for me.
Remove the following line from the class that extends RecyclerViewPager:
@Override public void setHasStableIds(boolean hasStableIds) { origin.setHasStableIds(hasStableIds); }
Have a good one and thanks @lsjwzh for the library!
I used next code in my fragment
When I open new fragment and returned back i got exception in last line:
When I used normal RecyclerView my code works well!