I am developing an application which heavily relies on the usage of RecyclerView.
I really need to know how to use the same RecyclerView for different item layouts. An example of layouts are:
1) A list item with a name and description
2) A list item with an Image and a name
You can see that they are similar, but with slight changes to the layout.
Thanks in advance!
Since the recyclerview item in xml doesn't depend on the kind of items that you will inflating in it, you can go ahead and use the same recycler view layout file for the three fragments.
As for the adapters, your lists seem to be homogeneous (i.e., single kind of view item). Its best that you use 3 different adapters for each case. You can customise the constructor, add custom helper methods for each kind of adapter as per your convenience.
Now if you have a heterogeneous list, you will have to override getItemViewType()
in your adapter and use this appropriately in onCreateViewHolder()
and onBindViewHolder()
Hope this helps! :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With