0
0
Android Kotlinmobile~20 mins

LazyColumn for lists in Android Kotlin - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
LazyColumn Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2: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)
  }
}
AA horizontal list showing the words: Apple, Banana, Cherry
BA vertical list showing the words: Apple, Banana, Cherry
CA vertical list showing numbers 0, 1, 2
DAn empty screen with no text
Attempts:
2 left
💡 Hint
LazyColumn creates a vertical scrolling list. The items function shows each element.
📝 Syntax
intermediate
2: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)
  }
}
AChange Text(index) to Text(text = "Item $index")
BAdd a comma after items(5), like items(5,)
CChange items(5) to items(count = 5)
DReplace LazyColumn with Column
Attempts:
2 left
💡 Hint
Text composable requires the text parameter name or a single string argument.
lifecycle
advanced
2: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")
ALazyColumn shows the old list and ignores the change
BLazyColumn clears all items and shows nothing
CApp crashes due to list mutation
DLazyColumn automatically updates to show the new list with Cherry added
Attempts:
2 left
💡 Hint
Jetpack Compose tracks state changes and recomposes UI automatically.
navigation
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)
  }
}
AAdd a click listener to the list variable fruits
BAdd onClick parameter to LazyColumn { onClick = { println(fruit) } }
CWrap Text in Modifier.clickable { println("Clicked: $fruit") }
DUse Button instead of Text without any modifier
Attempts:
2 left
💡 Hint
Use Modifier.clickable on the composable you want to be clickable.
🔧 Debug
expert
2: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])
  }
}
AAccessing fruits[index] causes IndexOutOfBoundsException
BUsing items(count) with a list requires itemsIndexed or items(list) instead
CLazyColumn cannot use items with a count parameter
DText composable cannot be used inside LazyColumn
Attempts:
2 left
💡 Hint
When using items(count), indices go from 0 to count-1. Check if list supports those indices.