您的当前位置:首页Android 输入框显示和隐藏

Android 输入框显示和隐藏

2024-06-19 来源:小侦探旅游网
private boolean ishide=true;
if (ishide) {
                    //设置EditText文本为可见的
                    metpasswordlogin.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
                } else {
                    //设置EditText文本为隐藏的
                    metpasswordlogin.setTransformationMethod(PasswordTransformationMethod.getInstance());
                }
                ishide = !ishide;
                metpasswordlogin.postInvalidate();
                //切换后将EditText光标置于末尾
                CharSequence charSequence = metpasswordlogin.getText();
                if (charSequence instanceof Spannable) {
                    Spannable spanText = (Spannable) charSequence;
                    Selection.setSelection(spanText, charSequence.length());
                }

 

因篇幅问题不能全部显示,请点此查看更多更全内容