Challenge - 5 Problems
LazyColumn Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What will this LazyColumn display?
Given the following Kotlin Compose code, what will the LazyColumn show on the screen?
Android Kotlin
LazyColumn {
items(listOf("Apple", "Banana", "Cherry")) { fruit ->
Text(text = fruit)
}
}Attempts:
2 left
💡 Hint
LazyColumn creates a vertical scrolling list. The items function shows each element.
✗ Incorrect
LazyColumn displays items vertically. Here, it shows each fruit name as a Text item.
📝 Syntax
intermediate2:00remaining
Identify the syntax error in this LazyColumn code
Which option correctly fixes the syntax error in this LazyColumn snippet?
Android Kotlin
LazyColumn {
items(5) { index ->
Text(index)
}
}Attempts:
2 left
💡 Hint
Text composable requires the text parameter name or a single string argument.
✗ Incorrect
Text composable expects a named parameter text or a single string argument. Text(index) passes an Int instead of String, causing a type mismatch.
❓ lifecycle
advanced2:00remaining
What happens when the list data changes in LazyColumn?
If the list passed to LazyColumn changes, how does the UI behave?
Android Kotlin
var fruits by remember { mutableStateOf(listOf("Apple", "Banana")) }
LazyColumn {
items(fruits) { fruit ->
Text(text = fruit)
}
}
// Later fruits = listOf("Apple", "Banana", "Cherry")Attempts:
2 left
💡 Hint
Jetpack Compose tracks state changes and recomposes UI automatically.
✗ Incorrect
When the state list changes, Compose recomposes LazyColumn to show the updated items.
advanced
2:00remaining
How to handle item clicks in LazyColumn?
Which code snippet correctly handles a click on each item in LazyColumn to print the clicked item?
Android Kotlin
val fruits = listOf("Apple", "Banana", "Cherry") LazyColumn { items(fruits) { fruit -> Text(text = fruit) } }
Attempts:
2 left
💡 Hint
Use Modifier.clickable on the composable you want to be clickable.
✗ Incorrect
Modifier.clickable on Text allows detecting clicks and running code like println.
🔧 Debug
expert2:00remaining
Why does this LazyColumn cause a runtime error?
Examine this code and select the reason for the runtime crash.
Android Kotlin
val fruits = listOf("Apple", "Banana", "Cherry") LazyColumn { items(5) { index -> Text(text = fruits[index]) } }
Attempts:
2 left
💡 Hint
When using items(count), indices go from 0 to count-1. Check if list supports those indices.
✗ Incorrect
items(5) iterates indices 0 to 4, but fruits has only 3 elements (size=3), so fruits[3] and fruits[4] throw IndexOutOfBoundsException.