Build Another Fragment (Game)

We created GameFragment last chapter, but it still looks pretty sad, especially compared to the PickPlayersFragment. By the time we wrap up this chapter, we’ll have a screen that looks like the image shown.

images/pd.fragments/game-fragment-coin-slots.png

The rest of this chapter will be spent in GameFragment, so I recommend going to navigation/nav_graph.xml and setting app:startDestination to @id/gameFragment. Then, we’ll start by enabling data binding for GameFragment.

Enable Data Binding for GameFragment

As we’re just turning on data binding in GameFragment right now, all we need to do in fragment_game.xml is add that generic <layout> tag plus an empty <ConstraintLayout> ...

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.