Generic RecyclerView Adapter

Malwinder Singh
May 31, 2020


Iโ€™m writing this article in the situation when the whole world is lockdown due to Covid-19 but the developers donโ€™t stop working ๐Ÿ˜

Here is the code for generic RecyclerView Adapter:

Hereโ€™s how you can use it:

val apples = arrayListOf(
Apple(5f, 50f),
Apple(6f, 55f),
Apple(7f, 60f),
Apple(8f, 65f)

apples, R.layout.rv_list_item
) { _, itemData, itemView ->
(itemView as TextView).text = itemData.size.toString()

apples.add(Apple(9f, 66f))

Hope you liked this article!

Medium does not allow Indian writers to monetize currently ๐Ÿ˜ญ. Please support this blog by contributing here: ๐Ÿฅฐ

Buy me a coffee ๐Ÿฅฐ

Even a small contribution would help ๐Ÿ˜

If you have any questions, then please write down a response in the response section.
If you liked this article, then please press the ๐Ÿ‘ icon.
Thank you!
Peace! ๐Ÿ™‚



Malwinder Singh

Flutter, Kotlin & Android. Worked on projects of Emerson and Omron, 50k+ views on this blog, 6k+ repo on StackOverflow, Drone startup