Skip to content Skip to sidebar Skip to footer

Nested Recyclerview Issues

I have a fragment with parent RecyclerView and his child (the child is inner recyclerview). When I scroll to bottom (last data), and scroll it again to top, I found the problem. On

Solution 1:

When you scroll to bottom and again to top. the OnBindViewHolder method recall, so the inner Recyclerview will set adapter another time.

It's better to use NestedScrollView as a parent of fragment instead of RecyclerView

you may face a problem that the recyclerview slow when scroll. use this code to solve it and enhance the performance.

 recycleview.setNestedScrollingEnabled(false);
 ViewCompat.setNestedScrollingEnabled(recycleview, false);
 recycleview.setHasFixedSize(true);
 recycleview.setItemViewCacheSize(20);
 recycleview.setDrawingCacheEnabled(true);
 recycleview.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);

Now, you should use the code in the method OnBindViewHolder inside the onCreateView in your fragment to set the adapter for the inner recyclerView

tell me if you have any problem

Post a Comment for "Nested Recyclerview Issues"