I’m having an EditText which is a password field. Now I want to build a checkbox so that the user can decide if he wants to see the password with * or in plain text.
Therefore I built
if (passwordShouldBeVisible) {
etext_key1.setInputType(InputType.TYPE_CLASS_TEXT);
} else {
etext_key1.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT);
}
This works great but has the issue that if the password is plain the auto completion of the keyboard trys to help you.
Is there a chance to fix this?
Best regards,
Till
Try this:
eText_key1.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);Alternatively you can put the following in the XML definition of the EditText:
android:inputType="textFilter".EDIT:
Here’s an example, just make sure you are defining the settings in your toggle logic and your xml layout, or initializing the input type in your onCreate:
and here’s the XML file I am using: