Reputation: 2147
I want to implement an ConcatAdapter like this image:
This page's recyclerView contains these elements:
But the problem is I can set only one LayoutManager to recyclerView that holds ConcatAdapter as I know.
How can set different layoutmanager to each adapter? Or any other solution to implement this page with CocantAdapter?
(Why ConcatAdapter? Because it sovle performance prblems of nestedRecyclerView even with recyclerViewPool as I know)
Upvotes: 6
Views: 2779
Reputation: 597
Simple solution is to create a Viewpool in the Activity/Fragment. The Adapter for the recyclerview has 2 different types of items, The regular one and the other that actually has a recyclerview with the horizontal layout as Adapter in it.
So a Viewholder that holds a recyclerview inside with its own viewholders.
Then you just grab the created viewpool from the activity to assign it as the shared Pool to all of the adapters with the horizontal scroll, thats it :-)
Concat Adapter doesnt help with this im afraid so this would be my alternative solution
Upvotes: 1
Reputation: 5980
This unfortunately is not possible. A RecyclerView
adapter is just a component to provide and bind views for each row. A ConcatAdapter
is no different, it just redirects from the individual adapters.
If it did have any control over the layout managers it would really defeat the entire point of the modularity of RecyclerView
, which is what makes it so powerful in the first place.
You can take a look at the source code here to find out more about how it is implemented.
Upvotes: 3