Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change password field to diplay asterisks instead of dots

Tags:

android

I am working on the task that requires the password field (i.e.the Edit Text) to hide user input using asterisks(*) rather than dots(.). Currently it shows as dots. Kindly tell me the way to do it if its possible using android's native methods. Or please post the code to do it if anyone has already done that.

Thanks in advance..

like image 650
Sachin Avatar asked May 25 '11 13:05

Sachin


People also ask

How do I show asterisk in password field?

See Passwords Behind Asterisk in Google Chrome Open any website where you have your password saved, right-click on the password field and go to Inspect Element. When the HTML Editor opens, look for input type = “password” field and change “password” to “text” and press Enter to save.

How can I see my Iphone password instead of dots?

It will be normal to see the dots in place of the password in Settings > Passwords, until you tap on the Password box. After tapping on it, it should change the dots to the password. Cheers.

Can asterisk be used in Passwords?

Updated on August 18, 2021 . All browsers hide your passwords behind asterisks (or bullets) to prevent anyone nearby from stealing it. However, at times you may like to reveal the password behind asterisks. Like, while entering a long password you might like to ensure it's entered correctly.


1 Answers

Very late answer, and I'm sure you don't care anymore, but someone else might.

Initialize EditText Field .

 EditText UPL =(EditText) findViewById(R.id.UserPasswordToLogin) ;
    UPL.setTransformationMethod(new AsteriskPasswordTransformationMethod());

Then Create a new java class ,Called AsteriskPasswordTransformationMethod.java Which extends PasswordTransformationMethod

Here is code :

import android.text.method.PasswordTransformationMethod;
import android.view.View;

public class AsteriskPasswordTransformationMethod extends PasswordTransformationMethod {
    @Override
    public CharSequence getTransformation(CharSequence source, View view) {
        return new PasswordCharSequence(source);
    }

    private class PasswordCharSequence implements CharSequence {
        private CharSequence mSource;
        public PasswordCharSequence(CharSequence source) {
            mSource = source; // Store char sequence
        }
        public char charAt(int index) {
            return '*'; // This is the important part
        }
        public int length() {
            return mSource.length(); // Return default
        }
        public CharSequence subSequence(int start, int end) {
            return mSource.subSequence(start, end); // Return default
        }
    }
};
like image 164
IntelliJ Amiya Avatar answered Sep 28 '22 07:09

IntelliJ Amiya