Zmień znak maski hasła EditText na gwiazdkę (*)

Czy Jest jakiś sposób na zmianę tekstu hasła z kropki(.) na gwiazdkę (*).

Hasło jest wprowadzane w edittext.

<EditText
        android:id="@+id/passWord1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:inputType="number"
        android:password="true"/>
Author: Donald Duck, 2012-12-27

8 answers

Wstaw edittext do pliku xml,

<EditText
    android:id="@+id/passWordEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:inputType="textPassword"/>

I Twój plik klasy idź dalej i pobierz findViewById z edittext i zaimplementuj do tego,

EditText edittext = (EditText)findViewById(R.id.passWordEditText);
edittext.setTransformationMethod(new AsteriskPasswordTransformationMethod());

I ta klasa zaimplementuje do tego,

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
        }
    }
};
 41
Author: Najib Puthawala,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-04-11 10:10:03
<EditText
        android:id="@+id/passWord1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:inputType="textPassword"//here is the change. check it once in your xml
        android:password="true"/>

W eclipse pojawią się podpowiedzi po kliknięciu Ctrl + Spacja {[8] } Po przesunięciu kursora w android:inputType. Następnie możesz zobaczyć listę opcji. tam możesz wybrać textPassword

Jeśli chcesz zobaczyć * w miejsce . to sprawdź to Android: Asterisk Password Field

 19
Author: Ram kiran,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-07-02 06:55:48

Otrzymałem odpowiedź z pomocą linku zamieszczonego przez Ram kiran

text.setTransformationMethod(new AsteriskPasswordTransformationMethod());


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
    }
}
};
 5
Author: Sunny,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-08-17 05:55:00

Sprawdź poniżej link:-

Jeśli chcesz zobaczyć * w miejscu . następnie sprawdź to pole Android: Asterisk Password

Http://codemanteau.com/post/code_11

 1
Author: Kunal Dharaiya,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-11-13 06:07:33

Dla Androida: inputType, istnieje typ hasła.

 0
Author: TieDad,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-12-27 09:03:17

Odwiedź to pytanie stoskoverflow, odpowie na twoje pytanie

Jak zmienić pole hasła na gwiazdki zamiast kropek

 0
Author: Prateek,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 11:54:59

Spróbuj tego

android:inputType="textPassword"       
 0
Author: NagarjunaReddy,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-12-27 09:28:20
EditText.setTransformationMethod(new PasswordTransformationMethod());
 0
Author: Suresh,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-04-13 13:28:48