appwritten in Javaapp-kotlinis the same asappbut written in Kotlin
Creating a scrollable list of elements is a common pattern in mobile application. Using RecyclerView we can list a large data sets or frequently changing one. RecyclerView is an advanced and flexible version of ListView, addressing serveral issues with existing listing views. Here we will build a simple application with RecyclerView
We will build two versions of a simple app (one in Java and one in Kotlin) that displays a list of hard-coded instances of class Link in a RecyclerView. To display items on RecyclerView you need to the following:
RecyclerViewwidget added to the activity layout.- A class extending
RecyclerView.Adapter. - A class extending
RecyclerView.ViewHolder. - Layout for RecyclerView items.
Files we need for this app are shown in the image below.
app-listadapterbuilding recyclerview withListAdapter
ListAdapter for RecyclerView has been introduced in Revision 27.1.0 Release of Support Library. ListAdapter uses DiffUtil under the hood to compute list diffs on a background thread. This will help RecyclerView animate changes automatically with less work on the UI thread.


