Robert Menke
11/03/2020, 8:13 PMTextField
in alpha06 is that ImeAction.GO
doesn’t seem to be working the same way it was in previous versions.
val focusRequester = FocusRequester()
TextField(
value = text,
onValueChange = viewModel::setEmail,
label = { Text(text = "What's your email address?") },
placeholder = { Text(text = "<mailto:jane.doe@gmail.com|jane.doe@gmail.com>") },
keyboardType = KeyboardType.Email,
modifier = frameFillWidth(60.dp).focusRequester(focusRequester),
backgroundColor = MaterialTheme.colors.background,
imeAction = ImeAction.Go,
onImeActionPerformed = { action, keyboardState ->
submit()
}
)
onActive(callback = {
focusRequester.requestFocus()
})
Siyamed
11/03/2020, 8:15 PMRobert Menke
11/03/2020, 8:16 PMSiyamed
11/03/2020, 8:17 PMRobert Menke
11/03/2020, 8:18 PMonActive
block I’m able to get the keyboard working but obviously don’t have automatic focus. The issue is also intermittent and seems to happen more frequently when I launch without updating (quicker start up time bc of cache)Ralston Da Silva
11/03/2020, 8:47 PM@OptIn(ExperimentalFocus::class)
@Composable
fun TextFocusSample() {
val focusRequester = FocusRequester()
val textFieldValue = remember { mutableStateOf(TextFieldValue()) }
TextField(
value = textFieldValue.value,
onValueChange = { textFieldValue.value = it },
modifier = Modifier.focusRequester(focusRequester)
)
onActive { focusRequester.requestFocus() }
}
Robert Menke
11/03/2020, 9:32 PMsteelahhh
11/04/2020, 5:11 AMMantas Varnagiris
11/04/2020, 7:43 AM