Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with android password field, not hiding the last character typed

In Android, I create a password field like this:

    EditText text = new EditText(context);
    text.setTransformationMethod(PasswordTransformationMethod.getInstance());

Or like this, which seems to do the same thing:

    EditText text = new EditText(context);
    text.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);

I get a nice password field except for the last character typed by the user. It's visible on the screen for a few seconds before beeing masked with a dot.

Here is a screenshot: enter image description here

Do you know how to fix this behaviour please?

like image 545
Joel Avatar asked Jun 15 '11 15:06

Joel


1 Answers

This is expected behavior. With the soft keyboards on most devices, it is valuable feedback that they are typing the password correctly.

For a list of all of the different inputTypes you can specify and how they change the EditText,

see android inputTypes .

Also, it is possible to change this behavior by implementing your own TransformationMethod and setting it via setTransformationMethod(), but I would not recommend doing that. Users will expect the behavior you are seeing and by changing your app, you'll be providing an inconsistent user experience.

also check this android article

like image 188
Steve Prentice Avatar answered Oct 10 '22 03:10

Steve Prentice