Add the RecyclerView

Our first stop is the new RankingsFragment class and the RecyclerView component inside. We could add the new Fragment class just as we did before, with right-clicking the fragments package and choosing New > Fragment > Fragment (Blank). Take note that one of the options in that menu is Fragment (List); that would do a lot of the needed work for us.

But I said “could” generate the Fragment class for a reason. I want to create each piece by hand the first time so it’s clear what all goes into setting up a RecyclerView. Plus, Android Studio adds a bunch of code we don’t need, so let’s save ourselves the trouble of having to delete all of that stuff we don’t need. Go ahead and add a new class to the fragments package called ...

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.