Skip to content

Instantly share code, notes, and snippets.

@parthdesai1208
Last active February 10, 2022 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parthdesai1208/997876bce6cb34200ab6d7a8cfb1ff1f to your computer and use it in GitHub Desktop.
Save parthdesai1208/997876bce6cb34200ab6d7a8cfb1ff1f to your computer and use it in GitHub Desktop.
RecyclerView like in compose
@Preview
@Composable
private fun columnRecyclerView(names: List<String> = List(1000) { "$it" }) {
val context = LocalContext.current
Column(
modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
LazyColumn(modifier = Modifier.padding(vertical = 4.dp)) {
items(names) { name ->
Text(text = "left " + name + " right ", modifier = Modifier
.fillMaxSize()
.padding(10.dp)
.clickable {
Toast
.makeText(context, "Click at $name", Toast.LENGTH_SHORT)
.show()
}, textAlign = TextAlign.Center, style = MaterialTheme.typography.h5
)
Divider()
}
}
}
}
@parthdesai1208
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment