Android Data Binding Library — From Observable Fields to LiveData in two steps

Jose Alcérreca
Mar 25, 2019 · 2 min read
Image for post
Image for post
Illustration by Virginia Poltrack

Step 1: Replace Observable Fields with LiveData

If you are using Observable Fields directly in your data binding layout, simply replace ObservableSomething (or ObservableField<Something>) with LiveData<Something>.

Step 2 — Set the lifecycle owner for the LiveData

Binding classes have a method called setLifecycleOwner that must be called when observing LiveData from a data binding layout.


Android Developers

The official Android Developers publication on Medium

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store