Chapter 16. Adapters and Recyclers
We will achieve much in this brief chapter. We will first go through the theory of adapters and lists. We will then look at how we can use a RecyclerAdapter
instance in Kotlin code and add a RecyclerView
widget to the layout, which acts as a list for our UI, and then, through the apparent magic of the Android API, bind them together so that the RecyclerView
instance displays the contents of the RecyclerAdapter
instance and allows the user to scroll through the contents of an ArrayList
instance full of Note
instances. You have probably guessed that we will be using this technique to display our list of notes in the Note to self app.
In this chapter, we will do the following:
- Explore another type of Kotlin class – the inner class
- Look at the theory of adapters and examine binding them to our UI
- Implement the layout with
RecyclerView
- Lay out a list item for use in
RecyclerView
- Implement the adapter with
RecyclerAdapter
- Bind the adapter to
RecyclerView...