Issue
I'm currently implementing a recyclerview in Android which uses a grid layout for cards, displaying a number of items. Simple enough. In the design, we wish to have one design for the cards if there are below 10 items in the list and then display another design (a more compact one) when the list contains more than 10 items.
How to accomplish this in a recycler view? To me, it seems like the adapter is tightly coupled to the layout file for the big cards - so how do you create an adapter that can switch between two layout files depending on the number of items in the list?
Solution
You can create two ViewHolders in your adapter, see the accepted answer here: How to create RecyclerView with multiple view types
Answered By - Itamar Stern
Answer Checked By - Senaida (JavaFixing Volunteer)