0

In my Android project I have a complex RecyclerView. The structure of my RecyclerView looks like the attached image.

In a few words, I have a main RecyclerView which contains a CardView, within the CardView I have another RecyclerView and each element can expand and collapse.

I have tried using a nested RecyclerView implementation (which is easy to find in Google by typing "Nested RecyclerView"), but this implementation has a bottleneck. When I call onBindViewHolder it calls setAdapter method and causes a bug when I scroll the RecyclerView.

Could you please give me any tips on how to implement such RecyclerView? What is the best way of building such Recycler adapters?

Here is an image how it looks like

Here is what I found about my way of implementing RecyclerView

fernandospr
  • 2,976
  • 2
  • 22
  • 43
msfvenom
  • 15
  • 3
  • RecyclerViews should be used when you have many items and you don't want all of them in memory (therefore Android will recycle views). By checking your image, it seems that you only have three subitems per item, therefore I wouldn't use a RecyclerView for the subitems. You could have the main RecyclerView for the items, and then on each item you could manually inflate the subitems in a vertical `LinearLayout`. – fernandospr Sep 06 '20 at 15:29
  • The number of nested items is not fixed. It can be 10-20-50. And Each of them can expand-collapse too. There will be three level: 1st is a cards with a lists, each item of each list can expand-collapse, and in expanded item will be a layout with Views and another one RecyclerView – msfvenom Sep 06 '20 at 15:31

1 Answers1

-1

This can be easily done with Concat Adapter.

https://www.youtube.com/watch?v=n_mrrva_z

this is my Mockup app using Concat adapter.

Think of Concat Adpater as an arrayList. Its coded like ConcatAdapter(HeaderAdapter, Adapter2, HorizontalAdapter)

Branddd
  • 78
  • 12
  • The video you attached is not available(( – msfvenom Sep 07 '20 at 12:46
  • I found that Groupie library can help me. It makes my RecyclerView a bit faster than earlier, but It still work pretty slow when I add > 100 nested elements – msfvenom Sep 07 '20 at 12:48
  • Could you please open the video? It's restricted for me to watch – msfvenom Sep 07 '20 at 12:56
  • https://youtu.be/o-4OfxfpZMo try this one @msfvenom The link highlights what it would look like if i combine 2 views with concat adapter. – Branddd Sep 07 '20 at 14:53