For example, after some modification to the sample code snippet given in android developer's site
@Composable
fun ClickCounter(clicks: Int, onClick: () -> Unit) {
Button(onClick = onClick) {
Text("I've been clicked $clicks times")
}
}
it is possible to count the number of times a button is pressed and display this count by changing the string in the Text component in the UI. However this needs the user to physically press the button to get Text to change. Is there a way to do this programmatically? I would like to perform some calculation and somewhere else and when the result is ready, display it by updating Text (doing something like Text.setText("...") had I been using xml to generate the UI). How do I change the value of Text programmatically? Do any of the jetpack compose sample programs from google have a simple example of this?
