gpt4 book ai didi

Android Jetpack Compose TextField 禁用键盘自动建议

转载 作者:行者123 更新时间:2023-12-04 13:24:39 57 4
gpt4 key购买 nike

我正在寻找一种使用 TextField Composable 禁用键盘自动建议的方法。
在大约 4 个月前的 Android 旧时代,使用 EditText 你可以做这样的事情,将 inputType 设置为 textNoSuggestions|textVisiblePassword .

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textNoSuggestions|textVisiblePassword" />
我在这里使用了两种 inputType,因为并非所有键盘都支持 textNoSuggestions field 。
Jetpack Compose 的 TextField 有没有办法做到这一点? ?我在他们的 KeyboardOptions 中没有看到任何内容模仿这个功能。

最佳答案

var text by remember { mutableStateOf("") }
TextField(
value = text,
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Email,
autoCorrect = false
),
onValueChange = {
text = it
}
)
我们可以使用 autoCorrect = false。
但是,根据文档, autoCorrect 参数:
"通知键盘是否启用自动更正。仅适用于基于文本的 KeyboardTypes,例如 KeyboardType.Email、KeyboardType.Uri。它不会应用于 KeyboardTypes,例如 KeyboardType.Number。大多数键盘实现会忽略此值,例如 KeyboardTypes键盘类型.文本。”
因此,请注意您使用的键盘类型。

关于Android Jetpack Compose TextField 禁用键盘自动建议,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69290080/

57 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com