The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.

The Data Binding Framework

To quote Rudyard Kipling:

East is East and West is West, and never the twain shall meet

In many programming environments, including classical Android development, one could paraphrase Kipling as “models are models and views are views, and never the twain shall meet, except by means of some controller or presenter or something”. The result is a fair amount of code that populates views with model-supplied data and updates those models as the user alters the data in the views (e.g., types something in an EditText widget).

Data binding, in general, refers to frameworks or libraries designed to help simplify some of this data migration, where the definitions of the models and views can be used to automatically “bind” them without as much custom controller- or presenter-style logic.

Interest in data binding spiked in 2015, when Google released the first beta editions of data binding support via Android Studio, the Android Gradle Plugin, and a new data-binding support library.

This chapter explores Google’s data binding support and how to use it to simplify your Android app development.


This chapter requires that you have read the core chapters of this book. In particular, the sample apps are based off of samples from the chapter on Internet access. Also, some samples use RecyclerView.

The What, Now?

In that chapter on Internet access, we examined a few variations of a sample app that retrieved the latest android questions from Stack Overflow and displayed them in a ListView. Our QuestionsFragment had an ItemsAdapter for populating the ListView, complete with a typical getView() implementation:

    setListAdapter(new ItemsAdapter(questions.items));

  class ItemsAdapter extends ArrayAdapter<Item> {
    ItemsAdapter(List<Item> items) {
      super(getActivity(), R.layout.row,, items);

    public View getView(int position, View convertView, ViewGroup parent) {
      View row=super.getView(position, convertView, parent);
      Item item=getItem(position);
      ImageView icon=(ImageView)row.findViewById(;


      TextView title=(TextView)row.findViewById(;


Some parts of getView() are clearly distinct for this application, notably using Picasso to download the question asker’s avatar and using Html.fromHtml() to handle HTML-style entities in the title.

However, the general process used here in getView() is fairly rote:

Data binding, as a general technique, aims to reduce that rote coding by declaratively telling a framework how to pull data from model objects (e.g., instances of Item) and pour that data into widgets (e.g., ImageView and TextView).

The Basic Steps

The preview of this section is out seeking fame and fortune as the Dread Pirate Roberts.

The Extended Layout Resource

The preview of this section left for Hollywood to appear in a reality TV show.

The Binding Expression Language

The preview of this section was abducted by space aliens.

Observables and Updating the Binding

The preview of this section is off trying to sweet-talk the Khaleesi into providing us with a dragon.

Two-Way Binding

The preview of this section is sleeping in.

Other Features of Note

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