简体   繁体   English

android EditText用什么inputType避免文本提示

[英]android EditText what inputType to avoid text suggestions

one of my biggest peeves is how some android keyboards make text suggestions come up with no way to hide the keyboard. 我最大的烦恼之一是某些android键盘如何使文本提示无法隐藏键盘。 I think this has something to do with the kind of editable field is being focused. 我认为这与正在关注的可编辑字段有关。

What inputType will make this never happen? 什么inputType可以使这种情况永远不会发生? I never want to see android word suggestions when I am trying to have a user log in, for instance. 例如,当我尝试让用户登录时,我从不希望看到android word建议。

If you want to do it programmatically, then you can use the following code to avoid text suggestions on all keyboard types. 如果要以编程方式进行操作,则可以使用以下代码来避免在所有键盘类型上出现文本建议。

//assume an EditText object with name myEditText
myEditText.setInputType(myEditText.getInputType() | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS does not seem to work as expected on all keyboards whereas InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD has the drawback that it also disables toggling the language in the keyboard and the swipe gesture to add the text. InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS似乎不能在所有键盘上都能正常工作,而InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD的缺点是,它也无法切换键盘语言和滑动手势以添加文本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM