Your First Kotlin Android App: Polishing the App

Aug 22 2023 · Kotlin 1.8.20, Android 13, Android Studio Flamingo | 2022.2.1

Part 1: Build Out the App

04. Display the Score

Episode complete

Play next episode

About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 03. Add Other Game Controls Next episode: 05. Keep Track of Game Rounds

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 04. Display the Score

Note: It is important to note that the order at which you pass in arguments doesn’t matter when using named arguments. For more information, see Programming in Kotlin. \

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

Now that we’re done with the UI part, it’s time to increment and display the score in the score board.

var totalScore by rememberSaveable { mutableStateOf(0) }
totalScore = totalScore + pointsForCurrentRound()
totalScore += pointsForCurrentRound()
  totalScore = totalScore, // New Code
  modifier = Modifier.fillMaxWidth()
fun GameDetail(
  modifier: Modifier = Modifier
  totalScore: Int = 0, // New Code
) {
GameInfo(label = stringResource(id = R.string.score_label), value = totalScore)