Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to set password property in an edit text?

I need to create a login form with 'username' 'password' fields and two buttons 'login' and 'cancel' in my android application.

I am using an alert dialog with edittext inside that.

This is the code I used to create password edittext..

     final EditText Password = new EditText(this);      Password.setGravity(Gravity.CENTER);      Password.setHint("Password");      Password.setWidth(200);       Password.setTransformationMethod(new PasswordTransformationMethod());      login_alert.addView(Password); 

My issue is that, plain text is shown instead of 'dots' when i open a softkeypad to edit the password. (It is shown as dots when not in softkeypad mode)

Can anyone suggest a solution?

like image 211
Dhanesh Avatar asked May 23 '11 08:05

Dhanesh


People also ask

How do I change my toggle password in EditText?

app:passwordToggleDrawable - Drawable to use as the password input visibility toggle icon. app:passwordToggleTint - Icon to use for the password input visibility toggle. app:passwordToggleTintMode - Blending mode used to apply the background tint. More details in TextInputLayout documentation.

How can I hide my password while typing in android?

Just go into general, security, then scroll till you find 'make passwords visible' (show password characters briefly when you type them) this will stop the letters coming up for a short period of time and will reduce the chances of someone reading your password when you type it in.


1 Answers

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

This one works for me.
But you have to look at Octavian Damiean's comment, he's right.

like image 184
ernazm Avatar answered Sep 20 '22 12:09

ernazm