How to add cards with different layouts using CardArrayRecyclerViewAdapter?

62 Views Asked by At

How can I add cards with different layouts using CardArrayRecyclerViewAdapter. Specifically I am interested in having a header followed by cards with different layouts?

1

There are 1 best solutions below

1
Alberto S. On

The adapters for RecyclerView have a method called getItemViewType(). That type is passed to 'onCreateViewHolder()' so you can inflate different layouts.

So you only need to override getItemViewType() and return different values depending on each layout you want to inflate