Level 4
Lists (The new RecyclerView)
LazyColumn for Lists
`LazyColumn` renders only what is on screen. It replaces the complex RecyclerView + Adapter boilerplate.
📚 Explanation
`LazyColumn` is Compose's equivalent to RecyclerView. It only composes visible items, making it efficient for large lists. The `items` function provides a DSL for defining list content.
Note: Code execution is not available for Android/Kotlin in the browser. Use Android Studio to run and test the app.
import androidx.compose.foundation.lazy.LazyColumnimport androidx.compose.foundation.lazy.items@Composablefun ChatList(messages: List<String>) {LazyColumn(contentPadding = PaddingValues(16.dp),verticalArrangement = Arrangement.spacedBy(8.dp)) {// DSL for defining list contentitems(messages) { message ->Text(text = message, modifier = Modifier.padding(8.dp))}}}