Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use numberPassword input type and still see the input?

Can I use numberPassword as input type and still see the input?

My goal is to have a 0-9 keyboard with as few as possible other keys (that's why I prefered numberPassword over phone), but the user should still be able to see what he just typed.

This is what I have, but right now the passwords are hidden behind asterisks.

android:digits="1234567890"
android:inputType="numberPassword"

Note: I also tried setInputType(InputType.TYPE_NUMBER_VARIATION_PASSWORD), which made the input visible, but changed the keyboard from numbers-only to a regular keyboard. I need they keyboard to display numbers-only though.

like image 917
keinabel Avatar asked Sep 11 '25 17:09

keinabel


2 Answers

This did the job:

uEditText = (EditText) findViewById(R.id.editText);
uEditText.setTransformationMethod(null);
like image 150
keinabel Avatar answered Sep 14 '25 07:09

keinabel


In Java, just do this:

edittext.setTransformationMethod(PasswordTransformationMethod.getInstance());

If you wanted to hide the password later on, you would just do this:

editText.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
like image 32
ᴛʜᴇᴘᴀᴛᴇʟ Avatar answered Sep 14 '25 06:09

ᴛʜᴇᴘᴀᴛᴇʟ