The following is the first few sections of a chapter from Exploring Android, plus headings for the remaining major sections, to give you an idea about the content of the chapter.


Populating Our RecyclerView

We now have a repository with some fake to-do items. It would be helpful if the user could see these items in our MainActivity and its RosterListFragment. We have a RecyclerView in that fragment, and now we need to tie the data from the repository into the RecyclerView.

Right now, we are going to take a fairly simplistic approach to the problem, having the fragment work directly with the repository. That will work for now, but it is not a great choice. Once we start allowing the user to view and edit to-do items, plus start saving this data in a database, we will need a more sophisticated approach. But, that is a task for the future — today, we will keep it simple.

However, we will explore another feature of the Android ecosystem: the data binding framework. This makes it a bit easier to pour data from objects, such as our ToDoModel objects, into UI layouts.

This is a continuation of the work we did in the previous tutorial. The book’s GitHub repository contains the results of the previous tutorial as well as the results of completing the work in this tutorial.

Read Me!

This tutorial assumes that you have learned about RecyclerView and data binding from somewhere. That could be:

Step #1: Adding Data Binding Support

The preview of this section is in an invisible, microscopic font.

Step #2: Defining a Row Layout

The preview of this section was abducted by space aliens.

Step #3: Adding a Stub ViewHolder

The preview of this section apparently resembled a Pokémon.

Step #4: Creating a Stub Adapter

The preview of this section was the victim of a MITM ('Martian in the middle') attack.

Step #5: Retrieving Our Model Data

The preview of this section was whisked away by a shark-infested tornado.

Step #6: Adding the Data Binding

The preview of this section was the victim of a MITM ('Martian in the middle') attack.

Step #7: Completing the Adapter

The preview of this section apparently resembled a Pokémon.

Step #8: Wiring Up the RecyclerView

The preview of this section is en route to Mars.

Step #9: Seeing the Results

The preview of this section was stepped on by Godzilla.

What We Changed

The preview of this section is presently indisposed.