【发布时间】:2021-09-20 05:51:12
【问题描述】:
有谁知道如何在AlertDialog 中显示或隐藏键盘?
focusManager.clearFocus() 在AlertDialog 中不起作用。
textInputService?.hideSoftwareKeyboard() 和 softwareKeyboardController?.hide() 相同。
例如:
AlertDialog(
onDismissRequest = {
openDialog.value = false
},
text = {
TextField(...)
}
buttons = {
Button(
modifier = Modifier.fillMaxWidth(),
onClick = { focusManager.clearFocus() }
) {
Text("Update")
}
}
)
【问题讨论】:
-
请添加您的代码。你是如何隐藏键盘的?
-
@SK.Fuad 添加了示例代码,谢谢。
标签: android kotlin android-jetpack-compose