I use an EditText to enter password. And a CheckBox to show password or not. Below function is the part:
public void ShowPassword() { if (cb.isChecked()) {
This will work -
public void ShowPassword() { if (cb.isChecked()) { password.setInputType(InputType.TYPE_CLASS_TEXT); } else { password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } }