From the course: Android Development: Data Binding

What is data binding? - Android Tutorial

From the course: Android Development: Data Binding

Start my 1-month free trial

What is data binding?

- [Instructor] So what exactly is data binding? And how can it improve our Android apps? So to put it simply, the Android Data Binding Library makes it easy to connect your app's data to the user interface without having to write a bunch of boilerplate code. Now, conceptually, it works like this. In your application, you have one or more objects that contain the data for your app. And your app also has a set of activities that represent various parts of your app's user experience and these activities contain various user interface elements and controls like text boxes, buttons, lists, you get the idea. The Data Binding Library gives you a way of connecting your app's data to the various parts of your UI and doing so declaratively right in the XML layout definition for your activity. Now, this is what lets you get rid of all those find view by ID calls from your activity code. You can specify right in your layout, which parts of your data model are represented by which parts of the UI. There's also a rich layout expression language that you can use with your data objects to drive new data from existing data without having to change your business logic or your data classes. Now, you can define different kinds of relationships between layout and the data. So for example, some piece of data might only go one way, from the data model right into your layout. Other pieces of data might go two ways. So changes in the model are reflected in the layout and changes that are made within the layout are updated back inside the model. So we're going to examine each of these concepts during the course and by the time we're finished, you'll have the foundational knowledge that's needed to start using data binding within your own apps.

Contents