Code to show password in Android

26 Sep

* To show the dots instead of the password set the PasswordTransformationMethod:
yourEditText.setTransformationMethod(new PasswordTransformationMethod());

*To re-show the readable password, just pass null as transformation method:

– Take CheckBox in layout.
– Give id as chkShowPassword.
– Bind it as shown below.
– Import setOnClickListener to handle the click event.
– And perform the action.

private void showPassword()
final CheckBox checkbox = (CheckBox) findViewById(;
checkbox.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// Perform action on clicks, depending on whether it’s now checked
if (((CheckBox) v).isChecked())
etxtPassword.setTransformationMethod(new PasswordTransformationMethod());

Leave a comment

Posted by on September 26, 2011 in Android Source Code


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: