0
0
Android Kotlinmobile~10 mins

LazyColumn for lists in Android Kotlin - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a LazyColumn that displays a list of items.

Android Kotlin
LazyColumn {
    items([1]) { item ->
        Text(text = item)
    }
}
Drag options to blanks, or click blank then click option'
AlistOf("Apple", "Banana", "Cherry")
BColumn
CRow
DBox
Attempts:
3 left
💡 Hint
Common Mistakes
Using layout components like Column or Row instead of a list.
Forgetting to pass a list to items.
2fill in blank
medium

Complete the code to add padding around each item in the LazyColumn.

Android Kotlin
LazyColumn {
    items(listOf("Dog", "Cat", "Bird")) { item ->
        Text(text = item, modifier = Modifier.[1](8.dp))
    }
}
Drag options to blanks, or click blank then click option'
Amargin
Bpadding
CfillMaxSize
Dbackground
Attempts:
3 left
💡 Hint
Common Mistakes
Using margin which is not a Compose modifier.
Using fillMaxSize which changes size but not padding.
3fill in blank
hard

Fix the error in the LazyColumn code by completing the blank with the correct parameter name for the item key.

Android Kotlin
val items = listOf("Red", "Green", "Blue")
LazyColumn {
    items(items, [1] = { it }) { color ->
        Text(text = color)
    }
}
Drag options to blanks, or click blank then click option'
Akey
Bid
Cindex
Dtag
Attempts:
3 left
💡 Hint
Common Mistakes
Using id or index which are not valid parameters here.
Omitting the key parameter causing recomposition issues.
4fill in blank
hard

Fill both blanks to create a LazyColumn that displays numbers from 1 to 5 with each number doubled.

Android Kotlin
LazyColumn {
    items([1]) { number ->
        Text(text = "Number: ${number [2] 2}")
    }
}
Drag options to blanks, or click blank then click option'
AlistOf(1, 2, 3, 4, 5)
B*
C+
DlistOf(5, 4, 3, 2, 1)
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of multiplication.
Using a reversed list which changes the order.
5fill in blank
hard

Fill all three blanks to create a LazyColumn that filters a list of words to show only those longer than 4 letters, displaying the word in uppercase.

Android Kotlin
val words = listOf("apple", "bat", "carrot", "dog", "elephant")
LazyColumn {
    items(words.filter { [1] [2] 4 }) { word ->
        Text(text = word.[3]())
    }
}
Drag options to blanks, or click blank then click option'
Aword.length
B>
Cuppercase
Dlowercase
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase instead of uppercase.
Using less than operator which filters wrong words.