This post is from a low-reputation account and contains an unverified outbound link. Be cautious before clicking external links.

RecyclerView-in-Kotlin

basav(26)
Published in
#kotlin
Words
134
Reading
1 min
Listen
Play
8y

#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
Screenshot_20180520-152947.png

RecyclerView-in-Kotlin | Ecency