why TYPE_TEXT_FLAG_NO_SUGGESTIONS is not working to disable auto corrections?

Viewed 829

I have a TextEdit where the user can enter their name. I do not want the editor to auto-correct spelling mistakes. I try to do :

myEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

but this didn't do anything. Why?

1 Answers

TYPE_CLASS_TEXT and TYPE_TEXT_FLAG_NO_SUGGESTIONS are static variables belonging to InputType class. You have to use them as follows:

myEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

EDIT: As suggested in this answer, some keyboards ignore InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS. So using InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD is a common workaround which you said you've already implemented.

Related