Build the List Item Layout

The end goal for this section is to get PlayerSummaryAdapter ready for use, but the class and layout files I mentioned before should be completed first. That class, PlayerSummary, is a basic data class used to hold the win and games played totals for each user. We’ll use this class to determine what to display in each line item. The code for the class looks like this:

 package​ ​dev.mfazio.pennydrop.types
 
 data class​ PlayerSummary(
 val​ id: Long,
 val​ name: String,
 val​ gamesPlayed: Int = 0,
 val​ wins: Int = 0,
 val​ isHuman: Boolean = ​true
 )

Not much else to say here, so we can move on to where we’ll use instances of the PlayerSummary class, a new layout file called player_summary_list_item.xml ...

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.