在隐藏密码字符之前先显示一会儿 [英] Show password characters for a short while before hiding them

查看:114
本文介绍了在隐藏密码字符之前先显示一会儿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我实现了自己的数字键盘,用于输入(基于数字的)密码. 密码"或更确切地说是点"表示形式,显示在数字键盘上方4个框中实现的4个EditText上.当您输入数字时,其中一个框将被一个圆点填充-为此,我使用TransformationMethod PasswordTransformationMethod-但我希望您打孔的数字在隐藏之前会在短时间内可见(例如〜200ms ).

In my application I've implemented a num-pad of my own, which is used for entering (number-based) passcodes. The 'password', or rather the 'dot'-representation of it, is shown on 4 EditTexts implemented in 4 boxes above the num-pad. When you enter a number one of those boxes will get filled in with a dot - for this I use the TransformationMethod PasswordTransformationMethod - but I'd want the number you punch in to be visible for a short while before it gets hidden (Like ~200ms).

在Android中是否可以立即执行此实现,或者您将如何以最佳方式实现此实现?我敢肯定,您知道我的意思,它经常用于基于移动设备的密码输入.

Is there any implementation of this readily-done in Android or how would you implement this the best way? I'm sure you know what I mean, it's used quite frequently for mobile-based password entering.

提示后的代码:

codeField1 = (EditText) findViewById(R.id.passcode_1);
codeField2 = (EditText) findViewById(R.id.passcode_2);
codeField3 = (EditText) findViewById(R.id.passcode_3);
codeField4 = (EditText) findViewById(R.id.passcode_4);

new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            codeField1.setTransformationMethod(PasswordTransformationMethod.getInstance());
            codeField2.setTransformationMethod(PasswordTransformationMethod.getInstance());
            codeField3.setTransformationMethod(PasswordTransformationMethod.getInstance());
            codeField4.setTransformationMethod(PasswordTransformationMethod.getInstance());
       }
    }, 2000);

仍然给我带来了问题,仅影响我输入的第一个.(所有这些都在onCreate()中.)

Still giving me issues, only effect on the first one I enter.. (All this is in onCreate()).

推荐答案

尝试此代码..

这将在2秒后隐藏文本,您可以根据自己的要求进行更改.

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

这篇关于在隐藏密码字符之前先显示一会儿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆