Sandah Aung
Sandah Aung

Reputation: 6188

Calling EditText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD) does not change text field to a password field

I have an EditText field in my Android app named password

When I called password.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD), the field does not change into a password text field. Why is this and what can I do to make it a password field at runtime?

Upvotes: 6

Views: 2673

Answers (1)

Melquiades
Melquiades

Reputation: 8598

You need to combine 2 flags:

password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);

Check the other examples in the docs for InputType class.

Upvotes: 12

Related Questions