I am trying to type text into a text field in interactive mode and it's not working. But, doing it on a physical device works.
MainActivity.kt
@Preview(showSystemUi = true)
@Composable
fun HelloContentPreview()
{
HelloContent()
}
@Composable
fun HelloContent()
{
Column(modifier = Modifier.padding(16.dp)) {
var name by remember { mutableStateOf("") }
Text(
text = "Hello! $name",
modifier = Modifier.padding(bottom = 8.dp),
style = MaterialTheme.typography.h5
)
OutlinedTextField(
value = name,
onValueChange = {
name = it
Log.i(TAG, "HelloContent: onValueChange: $it")
},
label = { Text("Name") }
)
}
}
Interactive mode

Based on the answer in IssueTracker https://issuetracker.google.com/u/1/issues/236149640#comment8
This problem is fixed for now. At least for me, it works.
PS If it doesn't work for you, ensure you've changed the text value in the onValueChange callback in your @Preview composite! Like this:
@Preview(showBackground = true)
@Composable
private fun InputPrev() {
var textValue by remember { mutableStateOf("Text") }
MainTextInputField(
text = textValue,
onValueChange = {
textValue = it
}
)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With