RecyclerView-in-Kotlin
#Creating a new Android Project with Kotlin in Android Studio.
#Add Dependencies in build.gradle file
//picasso is an image loading/processing library
implementation 'com.squareup.picasso:picasso:2.71828'
//Retrofit Networking library
implementation "com.squareup.retrofit2:retrofit:2.3.0"
//Gson is a library that can be used to convert Java Objects into their JSON representation
implementation "com.squareup.retrofit2:converter-gson:2.3.0"
//RecyclerView
implementation 'com.android.support:recyclerview-v7:27.1.1'
#Adding User Interface in your main Layout file
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
#Create a single row item for your RecyclerView.
#Create a Model Class
#Create a Adapter class
Here, I created a custom adapter name MovieAdapter with ViewHolder.
The Holder contains the members of the layout to bind viewItems.
HereI used Picasso library for image loading.
Picasso.get().load(movieModel.image).into(itemView.imageView_movie)
#Creating RecyclerView And Set Data To Adapter Class
var linearLayoutManager = LinearLayoutManager(this)
var adapter = MovieAdapter(arrList)
recyclerView.layoutManager = linearLayoutManager
recyclerView.adapter = adapter
#You can access full code please visit below link
https://github.com/bkotagonde/RecyclerView-in-Kotlin/tree/master
Leave RecyclerView-in-Kotlin to:
Read more #kotlin posts
Best Posts From basav
We have not curated any of basav's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.