简体   繁体   中英

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. I think this has something to do with the kind of editable field is being focused.

What inputType will make this never happen? I never want to see android word suggestions when I am trying to have a user log in, for instance.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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