ListView and RecyclerView of Android


Principle of ListView and RecyclerView of Android

There are four components in using ListView or its better version RecyclerView:

  1. Adapter extended from
  2. ViewHolder extended from RecyclerView.ViewHolder
  3. Layout for each item.
  4. View model.

The adapter links a list to the instances of ViewHolder (via onBindViewHolder) each of which corresponds to an item and inflates the layout that displays the item.  Each view model corresponds to an item, and is passed to a ViewHolder by the adapter via onBindViewHolder.