Showing a scrollable list of items (contacts, notes, products) is one of the most common UI patterns in Android, and RecyclerView is the standard tool for it — it recycles off-screen item views instead of creating a new one for every row, which is what makes long lists scroll smoothly.

The three pieces

  1. A data class for each row’s data.
  2. A ViewHolder that holds references to one row’s views.
  3. An Adapter that connects your data list to the RecyclerView.
data class Note(val title: String, val body: String)

class NoteAdapter(private val notes: List<Note>) :
    RecyclerView.Adapter<NoteAdapter.NoteViewHolder>() {

    class NoteViewHolder(val binding: ItemNoteBinding) :
        RecyclerView.ViewHolder(binding.root)

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NoteViewHolder {
        val binding = ItemNoteBinding.inflate(
            LayoutInflater.from(parent.context), parent, false
        )
        return NoteViewHolder(binding)
    }

    override fun onBindViewHolder(holder: NoteViewHolder, position: Int) {
        val note = notes[position]
        holder.binding.titleText.text = note.title
        holder.binding.bodyText.text = note.body
    }

    override fun getItemCount(): Int = notes.size
}

Wiring it up in the Activity:

binding.notesRecyclerView.layoutManager = LinearLayoutManager(this)
binding.notesRecyclerView.adapter = NoteAdapter(myNotesList)