48.7 Initializing the RecyclerView Component
At this point the project consists of a RecyclerView instance, an XML layout file for the CardView instances and an adapter for the RecyclerView. The last step before testing the progress so far is to initialize the RecyclerView with a layout manager, create an instance of the adapter and assign that instance to the RecyclerView object. For the purposes of this example, the RecyclerView will be configured to use the LinearLayoutManager layout option.
There is a slight complication here because we need to be able to use view binding to access the recyclerView component from within the MainActivity class. The problem is that recyclerView is contained within the content_main.xml layout file which is, in turn, included in the activity_main.xml file. To be able to reach down into the content_main.xml file, we need to assign it an id at the point that it is included. To do this, edit the activity_main.xml file and modify the include element...