密码隐藏和显示

mNewTogBtn = (ToggleButton) findViewById(R.id.mTogBtn);
        mNewTogBtn.setOnClickListener(new View.OnClickListener() {
            
            @Override
            public void onClick(View arg0) {
                if(mNewTogBtn.isChecked()){
                    et_password.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
                    et_password.setSelection(et_password.getText().length());
                }else{
                    et_password.setTransformationMethod(PasswordTransformationMethod.getInstance());
                    et_password.setSelection(et_password.getText().length());//设置光标在文字后面
                    
                }
            }
        });

你可能感兴趣的:(密码隐藏和显示)