Last active
April 3, 2024 01:58
-
-
Save emedinaa/343802a61401ecec0fb6a914d91fd08a to your computer and use it in GitHub Desktop.
Compose
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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