Data Binding is really easy and can save you from a lot of boilerplate when connecting your data to the UI, and also to update it when something changes.
Here I show you an example from scratch, and how to apply it to the MVVM presentation pattern:
Data Binding, easy to learn and really powerful
You’re probably already tired of using findViewById, or maybe Kotlin Android Extensions worked for you for some time, but now you’re finding some edgy cases where you are missing some things.
Thanks to Data Binding, you’ll be able to do a strict match between the views in your XML and the properties in your binding object so that it doesn’t happen anymore.
Besides, if you’re using MVVM pattern, thanks to the integration with LiveData, listening to model changes will be a breeze. Let’s get ready in seconds!
And if you want to learn Kotlin from scratch, join my free training
Author: Antonio Leiva
I’m in love with Kotlin. I’ve been learning about it for a couple of years, applying it to Android and digesting all this knowledge so that you can learn it with no effort.
Join my free 2-hour training!