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:
- You can check the sample code on Github
- If you want to learn about MVVM, check this article
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