Generic RecyclerView Adapter
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)
)
rv.showData(
apples, R.layout.rv_list_item
) { _, itemData, itemView ->
(itemView as TextView).text = itemData.size.toString()
}
apples.add(Apple(9f, 66f))
rv.refresh()
Hope you liked this article!
Medium does not allow Indian writers to monetize currently 😭. Please support this blog by contributing here: https://www.patreon.com/malwinder 🥰
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! 🙂