From the course: Android Development: Data Binding

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Binding to observables

Binding to observables - Android Tutorial

From the course: Android Development: Data Binding

Start my 1-month free trial

Binding to observables

- [Instructor] In this example, we're going to take our existing, simple data model and make it observable. So that changes to the data are reflected in the layout. So let's open the observable weather data class here in our editor. And we can see that this is a data class, just like our simple example, but in this case, the fields are observable data types. So we have observableInt for the temperature and the windchill and observable field of type string for the conditions. Let's also open up the observable fields activity, and we have some code that's similar to these simple example, but we just need to add our modifications. So first I'm going to instantiate an object of the observable weather data class. So I'm going to make a private value called obs_weather. And that going to be equal to a new observable weather data object. And then I'll pass in some values for the fields, so I'll pass an observableInt, and we'll…

Contents