Remove Delay for android textPassword

╄→尐↘猪︶ㄣ 提交于 2019-12-10 11:47:12

问题


While enterting password inside EditText view, Characters are being shown and after some delay it is shown as DOT, i want to remove this delay. It should be displayed directly as DOT.

How do i do this on Android?


回答1:


This is a user setting within Android, I do not believe that it is controllable from code. It is designed to aid the user in entering the correct password.

--Edit-- Further to the question askers comment, the setting can be found in:

Settings > Security > Make passwords visible

The above relates to Android ICS, the setting should be similar in previous versions.




回答2:


To Hide password forcefully,

android.provider.Settings.System.putInt(this.getContentResolver(),android.provider.Settings.System.TEXT_SHOW_PASSWORD, 0);

Note : It will not show any characters, Directly DOTs will be displayed without any delay inside your View having android:password attribute set to true




回答3:


Use code from AOSP PasswordTransformationMethod.java and modify it to suit your needs. Create new class MyPasswordTransformationMethod from it and modify the Visible class inside it. It would also need to change rest of the code because it accesses some private properties, but they are mostly constants so it is quite easy.

private static class Visible
extends Handler
implements UpdateLayout, Runnable
{
    public Visible(Spannable sp, MyPasswordTransformationMethod ptm) {
        mText = sp;
        mTransformer = ptm;
        //postAtTime(this, SystemClock.uptimeMillis() + 1500); 
        //replaced with following line
        postAtFrontOfQueue(this);
    }

    public void run() {
        mText.removeSpan(this);
    }

    private Spannable mText;
    private MyPasswordTransformationMethod mTransformer;
}


来源:https://stackoverflow.com/questions/11152379/remove-delay-for-android-textpassword

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!