Show password characters for a short while before hiding them

一个人想着一个人 提交于 2019-12-06 12:04:39

Try this code ..

this will hide the text after 2 second and you can change it based on your requi..

new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            edittext.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
            editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
        }
    }, 2000);  // set time based on your requirement

Use TextWatcher

Do not set the android:password="true" property in edittext.Instead use a textwatcher and in the addTextChangedListener() of the textwatcher replace the password with * after waiting for 200ms.

To wait use the following code:

private Handler mHandler = new Handler();
 mHandler.postDelayed(new Runnable() {
            public void run() {
                doStuff();
            }
        }, 2000);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!