Langsung ke konten utama

Postingan

Menampilkan postingan dari Juli, 2017

RecyclerView & ListView in Kotlin

In this tutorial, we will learn how to build ListView and RecyclerView with Custom Adapter in Kotlin. Everybody knows what is Listview and Recyclerview. So, without any introduction about them we will jump into the coding part of the Tutorial. Coding Part Kotlin ListView Example We should follow the same steps to create Activity with associated layout file for example MainActivity.kt with activity_main.xml Create ListView Adapter Create new class and named as MoviesListViewAdapter and paste the following. class MoviesListViewAdapter(private val activity: Activity, moviesList: List ) : BaseAdapter() { private var moviesList = ArrayList () init { this.moviesList = moviesList as ArrayList } override fun getCount(): Int { return moviesList.size } override fun getItem(i: Int): Any { return i } override fun getItemId(i: Int): Long { return i.toLong() } @SuppressLint("InflateParams", "ViewHolder")