I am using an EditText
box for user to enter their email address.
I set it up using:
box.setInputType( InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS );
This results in the soft keyboard popping up with the '@' and '.' (and some keyboards '.com') keys on the initial keyboard layout. Great just what I want.
However, I notice the text is all black (when I specified white). I found this is due to auto-suggest. If I go into Settings->Languages/Keyboards->Touch Input->TextInput
and disable Prediction and Word Completion, then the text shows up white.
Now the question: How do I get auto-complete programmatically disabled for this?
I have tried setting up the box by doing:
box.setInputType( InputType.TYPE_CLASS_TEXT | TYPE_TEXT_FLAG_NO_SUGGESTIONS );
This results in all white text (i.e. no auto-suggest). But then I longer have email '@' and '.com' buttons! Bah-humbug.
Anyway to get both? Thanks.
Users can enable or disable autofill as well as change the autofill service by navigating to Settings > System > Languages & input > Advanced > Input assistance > Autofill service.
To get the input type use getInputType() . int inputTypeValue = editText. getInputType(); The InputType values are defined (in hexadecimal) in the documentation.
The android:inputType attribute allows you to specify various behaviors for the input method. Most importantly, if your text field is intended for basic text input (such as for a text message), you should enable auto spelling correction with the "textAutoCorrect" value.
This code should do the trick:
box.setInputType( InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS );
You can add as many flags as you want, as long as they're compatible with each other.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With