键入时如何隐藏密码字母 [英] How to hide the letters of a password while typing
问题描述
我正在使用Android处理应用程序.我的要求是在用户输入密码时隐藏密码.我知道如何隐藏密码,但是在转换为不可读的格式之前,用户输入的密码会在一段时间内可见.任何人都可以在这方面帮助我.
I am dealing an application with Android. My requirement is hiding password while user is typing the password. I know how to hide the password but the password what the user typing is visible for a while before converting into unreadable format.Can anyone help me in this regard.
推荐答案
不要将默认的编辑文本属性设置为密码.相反,您可以使用 addTextChangedListener()
,一旦用户输入字符,该代码就会被调用.保持活动级别字符串,例如"mPass".在 TextWatcher()
中的 onTextChanged
方法中,将字符附加到mPass并将输入字符替换为*.
Don't set the default edit text property as password. Instead, you can use addTextChangedListener()
which will get called as soon as the user enters a character. Maintain an activity level string say "mPass". In the TextWatcher()
, onTextChanged
method, append character to your mPass and replace the input character by *.
但是,即使将字符替换为*,您也必须小心,因为该coz应用程序会将控制权传递给 TextWatcher()
.如果处理不当,它将被递归调用,从而导致应用程序崩溃.
But you will have to be careful regarding this coz application will pass control to the TextWatcher()
even after you have replaced the character by *. If not handled properly it will get called recursively causing the application to crash.
乏味的方式,但是可以使用...
Tedious way, but it will work...
这篇关于键入时如何隐藏密码字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!