Most applications typically work with data. Until recently, Android developers had to write a lot of code because of no first-class platform support for data binding.
Developers need to get the data for a database or user input and then assign values to the elements that present it to the user in the UI. This made Android data binding a pretty laborious, non-intellectual exercise for developers.
In Google IO 2015, a new data binding library was demonstrated; it removes the need to write such code. This library helps change the data binding development into the following three steps:
- Create a binding from a layout
- Retrieve the data
- Bind the data to the view
This reduction in code authoring is powered by code that is generated by the data binding library that analyzes the layout file. The Gradle plugin then creates a binding class file and then creates binding methods in the class file.
To use data the binding library, you will need to use a newer version of Android Studio and associated build tools. We also need to update the Android Plug-in for Gradle to version 1.3 or later, and add the latest Data Binding plugin. You can get these by installing or updating the Android Support Repository and Android Support library to the latest version.