Bind ViewModel to a Fragment (Pick Players)
Now it’s time for us to really get into the Data Binding library. So far, we’ve done a bunch of setup (sorry, there’s a bit more coming) and some static binding with isVisible and isChecked, but using dynamic variables is where data binding really shines. The ability to set up complex objects in our code, then bind them to the UI with minimal work is why I’m recommending data binding so emphatically. Working though this next section will set us up for later chapters where we’re displaying data from a database or web services. But first, we need to finish up a few more things to get this all working.
Update PickPlayersFragment to Use PickPlayersViewModel
To use the PickPlayersViewModel we just created, ...
Get Kotlin and Android Development featuring Jetpack now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.