Setting password input type to an Android EditText

In XML:

<EditText
    android:id="@+id/loginPassword"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:inputType="textPassword"
    ...
    />

In Java:

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

Leave a Reply

Your email address will not be published. Required fields are marked *