How can I add cards with different layouts using CardArrayRecyclerViewAdapter
. Specifically I am interested in having a header followed by cards with different layouts?
Asked
Active
Viewed 60 times
0
1 Answers
0
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

Alberto S.
- 7,409
- 6
- 27
- 46
-
In `onCreateViewHolder` the condition `this.mRowLayoutIds != null && this.mRowLayoutIds.length != 0` is considered. If condition is false, `BaseRecyclerViewAdapter` will inflate a base card layout for each row otherwise it will inflate a card layout based on the id in `mRowLayoutIds[viewType]`. Is my statement correct? – Oct 01 '15 at 07:10