How to use custom adapter for RecyclerView in Android

How to use custom adapter for RecyclerView in Android
December 24, 2018 No Comments Android Development,Development Pushpendra Kumar



Custom adapter for RecyclerView in Android with Kotlin

Android RecyclerView is an important component widely used in Android apps. It is important to know how to use it and how to customize its behavior. And for your kind information, I would like to tell you that, ListView is going to Replaced By Recycler View. Because if you see into your Design Window then you can find the Legacy Tab, After clicking on Legacy Tab you can find Listview is in Legacy. Means reducing the use of Listview and replacing it via Recycler View. And this officially announced in Android Summit December 2018.

ListView is in Legacy folder

So my main concern is to tell you the basic use of recycler view and how you can use it with custom adapter.

So First initialize your recycler view into XML as mention below.

Now Find it into your onCreate() Method as mention below.



Now Create code for your custom Adapter, Create a Kotlin Class for your adapter as mention below.

Now initialize this adapter from your activity with your string list. 

Perfect 👌🏻👌🏻👌🏻💫

You must be thinking why we have use GridLayoutManager For Recycler View. We use this for arranging view to the screen dynamically.

Also check this How to work with layoutInflater in Kotlin 

Good Luck Happy Coding 🙂 


Tags
About The Author
Pushpendra Kumar I am passionate about mobile application development and professional developer at Colour Moon Technologies Pvt Ltd (www.thecolourmoon.com). This website I have made so that I can meet with new challenges and can share here.

Leave a reply

Your email address will not be published. Required fields are marked *