带搜索栏的 Android 密码强度检查器

标签 android passwords textwatcher

如何在 android 中使用搜索栏创建密码强度检查器? enter image description here

最佳答案

您可以使用 https://github.com/VenomVendor/Password-Strength-Checker满足您的要求

或使用 TextWatcher用于检查EditText长度。像这样

 public void afterTextChanged(Editable s)
                    {
                                 if(s.length()==0)
                                        textViewPasswordStrengthIndiactor.setText("Not Entered");
                                 else if(s.length()<6)
                                        textViewPasswordStrengthIndiactor.setText("EASY");
                                 else if(s.length()<10) 
                                        textViewPasswordStrengthIndiactor.setText("MEDIUM"); 
                                 else if(s.length()<15) 
                                        textViewPasswordStrengthIndiactor.setText("STRONG");
                                   else 
                                        textViewPasswordStrengthIndiactor.setText("STRONGEST");

                               if(s.length()==20)
                                   textViewPasswordStrengthIndiactor.setText("Password Max Length Reached");
                    }
            };

Demo Help .

afterTextChanged (Editable s) - This method is called when the text has been changed. Because any changes you make will cause this method to be called again recursively, you have to be watchful about performing operations here, otherwise it might lead to infinite loop.

关于带搜索栏的 Android 密码强度检查器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32883969/

相关文章:

javascript - 登录和注册放在一起安全吗?

php - 在 CakePHP 中使用更安全的散列算法

android - 如何在 textView 更改文本时为 FadeOut 和 FadeIn 设置动画

android - 如何在 EditText 控件中的文本更改后 0.5 秒执行某些操作?

android - Facebook API wall post 方法会为 Post 和 Cancel 触发 onComplete?

android - 我在 Fragment 生命周期中遇到了麻烦,需要一个解决方案来摆脱它

java - 如何将条形码 Vision API 与 Google Cardboard 集成?

android - 移动网站比设备宽,捏一下就可以了

ASP.NET 成员(member)资格 - 让用户使用以前的密码

mvvm - 使用TextWatcher获取editText的旧值