I want to display recyclerview with sub items which needs to expand/collapse.
For example,
Main Item 1 (expand)
--- Child Item 1 (expand) ------- sub Item 1 ------- sub Item 2
--- Child Item 2 (expand) ------- sub Item 1
Main Item 2 (expand)
--- Child Item 1 (expand) ------- sub Item 1 ------- sub Item 2
--- Child Item 2 --- Child Item 3
Main Item 3 Main Item 4
When I click on mainitem it needs to show child items and when I click on child item 1 it needs to expand and display sub items.
How to do this in Android recyclerview..
Instead of recyclerview , you can use expandable recyclerview
For more info you can refer to :
https://github.com/thoughtbot/expandable-recycler-view
Edit:
To create your own custom expandable recycler view, you can use
ConcatAdapterto achive this. Refer to this article for more details:https://medium.com/codeshake/create-an-expandable-recyclerview-with-the-mergeadapter-254fd671fa5b