Android. RecyclerView with collapsing items

146 Views Asked by At

I need to create recyclerView with collapsing items. For example, I have a list of 10 items. By default, I only need to flip the first 2 elements. But by clicking on the "See all" button, I need to display all the items in the list. And vice versa, by clicking on the "Hide" button, you need to leave only the first two items in the list. Here is an example: enter image description here

I suppose to implement it like this: create a flag that determines whether the full list is displayed or not, and by clicking on the button, depending on the flag, send the full list to the adapter or cut it to two elements and call notifyDataSetChanged(). But this solution seemed to me not very good, perhaps there is a more elegant solution.

Note: I don't need nested collapsing elements. I just need to display two items from a list or all items.

Please help me.

0

There are 0 best solutions below