In my application, I have an EditText
whose default input type is set to android:inputType="textPassword"
by deault. It has a CheckBox
to its right, which is when checked, changes the input type of that EditText to NORMAL PLAIN TEXT. Code for that is
password.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
My problem is, when that CheckBox is unchecked it should again set the input type to PASSWORD. I've done it using-
password.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
But, the text inside that edittext is still visible. And for surprise, when I change the orienatation, it automatically sets the input type to PASSWORD and the text inside is bulleted (shown like a password).
Any way to achieve this?
Use this code to change password to text and vice versa. This code perfectly worked for me. Try this..
For kotlin users:
Complete code when you want to apply the Password visibility in Password edit text.
Create a handle [ Any drawable or Checkbox]
on click or on Checked/Uncheck write this:
Do not forget to write this line:
It resets the cursor to the end of line.