Add Fragments (Standings and Single Team)

Kotlin and Android Development featuring Jetpack — by Michael Fazio (73 / 125)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Add the Navigation Drawer | TOC | Pass Data with Safe Args 👉

We want two new fragments to support what we’re doing with Navigation in this chapter: StandingsFragment and SingleTeamFragment. We’ll link to the StandingsFragment in the nav drawer and SingleTeamFragment as a separate (non-nav drawer) destination that we access from both StandingsFragment and TeamsFragment.

All the code you want to copy can be found in the chapter-9/code-to-copy directory.

Add StandingsFragment

The Standings page is going to be another RecyclerView list, but with a twist: we’re going to add some headers into the list to split up the rows. Specifically, we’re adding headers to split the East and West divisions of the ABL. The Standings page at the end will look like this:

images/abl.navigation/abl-standings.png

Now, while I’d love to show you how all of this works, we have navigating to do. Given that, just go ahead and copy everything in the standings package into your project. That includes the following classes: StandingsAdapter, StandingsFragment, StandingsListItem, StandingsViewModel, TeamStanding, and UITeamStanding. Also, you need the…

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.