Complete the QuizQuestion composable function to achieve this output:
Checkbox, Radio Button, and Switch
Quiz implementation
Report a typo
Fill in the gaps with the relevant elements
@Composable
fun QuizQuestion() {
val options = listOf("Swift", "Kotlin", "Java", "Python")
val selectedAnswer = remember { mutableStateOf("") }
(modifier = Modifier.padding(16.dp)) {
("Which programming language is used for Android development?")
Spacer(modifier = Modifier.height(16.dp))
options.forEach { option ->
(verticalAlignment = Alignment.CenterVertically) {
(
= selectedAnswer.value == option,
= { selectedAnswer.value = option }
)
Text(option, modifier = Modifier.padding(start = 8.dp))
}
}
Spacer(modifier = Modifier.height(16.dp))
Text("Your answer: ${selectedAnswer.value}")
}
}Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.