MultipleView RecyclerView single selection in each ViewType

343 Views Asked by At

I have implemented multiple view type recycler view but I want to implement single selection for each view type as shown in image below

MultipleviewSingleSelectionForEachType

1

There are 1 best solutions below

1
On

What you're looking for is a Heterogeneous list with(in your case) a header and list items.

This is very easy to implement with a recyclerview using a Heterogeneous adapter(this is now very easy with view holder pattern).

As far as the selection is concerned, what you can do is save the selection in the arraylist, if the size of the arraylist is zero, implement a onLongClickListener on the list item viewType, and if the size is greater than zero, then just implement a normal click listener, and on successive selection store each list object type in that arraylist.