Set inputType for an EditText Programmatically?

user246114 picture user246114 · Apr 6, 2010 · Viewed 220.8k times · Source

How do we set the input type for an EditText programatically? I'm trying:

mEdit.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);

it doesn't seem to have any effect.

Answer

Amitku picture Amitku · Apr 27, 2011

For setting the input type for an EditText programmatically, you have to specify that input class type is text.

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