Skip to content

Instantly share code, notes, and snippets.

@mikkipastel
Last active January 16, 2023 15:13
Show Gist options
  • Save mikkipastel/f5efb85c7057f61374b60fe1cb3bb2b2 to your computer and use it in GitHub Desktop.
Save mikkipastel/f5efb85c7057f61374b60fe1cb3bb2b2 to your computer and use it in GitHub Desktop.
LazyColumn with Jetpack Compose (forEach + LazyListScope.item)
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val names = listOf("Stocker DAO", "Bittoon DAO", "Apetimism", "LonelyPop")
setContent {
MyTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.surface
) {
LazyColumn {
names.forEach {
item { Greeting(name = it) }
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment