Skip to content
Advertisement

Child RecyclerView setadapter doesn’t work on my Nested RecyclerView Android

I have two RecyclerViews. Parent RecyclerView works perfectly but the setadapter of the child’s in the parent adapter does not work.

I tried to make some log messages in the child adapter but they didn’t even appear so the adapter is not even starting

Below is the piece of code for better understanding.

MainFragment.java

JavaScript

ParentAdapter.java

JavaScript

ChildAdapter.java

JavaScript

Advertisement

Answer

That is because you must prefetch the child items first before you create its adapter using:

layoutManager.setInitialPrefetchItemCount(parentItem, .size());

you can find a full tutorial in here

https://www.geeksforgeeks.org/how-to-create-a-nested-recyclerview-in-android/

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement