Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an interactive Dice Roller app: Android Basics with Compose #175

Open
D4vc-198 opened this issue Jan 8, 2025 · 0 comments
Open

Comments

@D4vc-198
Copy link

D4vc-198 commented Jan 8, 2025

URL of codelab
https://developer.android.com/codelabs/basic-android-kotlin-compose-build-a-dice-roller-app?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-2-pathway-2&hl=es-419#6

In which task and step of the codelab can this issue be found?

  • Tastk 7: Compile the logic of the die
  • In the step: How to add a conditional to the dice roll app

Describe the problem

The content must be updated. Because it is currently being used

Button(onClick = { result = (1..6).random() }

When it really should be

onClick = { result.value = (1..6).random() }

This can cause confusion for some students who are beginners.

The same happens in the declaration when

val imageResource = when (result) {
    1 -> R.drawable.dice_1
    2 -> R.drawable.dice_2
    3 -> R.drawable.dice_3
    4 -> R.drawable.dice_4
    5 -> R.drawable.dice_5
        else -> R.drawable.dice_6
}

It really should be like this:

val imageResource = when (result.value) {
        1 -> R.drawable.dice_1
        2 -> R.drawable.dice_2
        3 -> R.drawable.dice_3
        4 -> R.drawable.dice_4
        5 -> R.drawable.dice_5
        else -> R.drawable.dice_6
    }

Steps to reproduce?

  1. Go to...
  2. Click on...
  3. See error...

Versions
Android Studio version:
API version of the emulator:

Additional information
Include screenshots if they would be useful in clarifying the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant