Skip to content

Instantly share code, notes, and snippets.

@emedinaa
Last active April 3, 2024 01:58
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 emedinaa/343802a61401ecec0fb6a914d91fd08a to your computer and use it in GitHub Desktop.
Save emedinaa/343802a61401ecec0fb6a914d91fd08a to your computer and use it in GitHub Desktop.
Compose
@Composable
fun Main(list: List<String>) {
var items by remember { mutableStateOf(list) }
LazyColumn {
items(items) { item ->
RowView(item) { str ->
val pos = items.indexOf(str)
Log.v(TAG, "pos $pos")
if(pos!= -1) {
items = items.toMutableList().apply {
set(pos, "xxx $str")
}
}
}
}
}
}
@Composable
fun RowView(name: String, actionItem:(String) -> Unit) {
val text by remember { mutableStateOf(name) }
Text(text = name, modifier = Modifier
.fillMaxSize()
.clickable {
actionItem(text)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment