The RecyclerView.Adapter class is used to bind a dataset to a RecyclerView to be displayed to a user. As I explained in another post, RecyclerView Vs ListView, the RecyclerView.Adapter forces the use of the ViewHolder pattern, which may be hard to understand when switching to a RecyclerView from a ListView. In this short post I am going to reference my MovieAdapter class from my Swipe-To-Dismiss example, and break it down to explain the required implementations and how to use the RecyclerView adapter.

Introduced in API 21 (Android 5.0), along with other MaterialDesign components, was the RecyclerView widget. This widget is a more flexible version of the ListView, which to many developers was their go-to AdapterView for applications.

It is important to note here, though, that the RecyclerView does not extend from the AdapterView class. Intuitively, it sounds like it would as an AdapterView is defined in the docs as:

An AdapterView is a view whose children are determined by an Adapter.

In the AdapterView design, the Adapter is the component responsible for mapping content from the data source to the Views of an AdapterView which are displayed to the user. Through the use of Adapters and LayoutManagers, the RecyclerView is able to break up responsibilities of the layout and create opportunities for more unique designs, which are explained in further detail later. Before we discuss the opportunities given to us by the RecyclerView, let’s go over some of the benefits of the ListView (in comparison to the RecyclerView), and where it fell short.