zoukankan      html  css  js  c++  java
  • Android完美解决输入框EditText隐藏密码打勾显示密码问题

    长话短说,一共有两种方法。首先你需要在布局文件里面给EditText设置一个android:inputType="numberPassword"属性。我这里默认规定密码只能是数字了。如果你需要你的密码不止是数字,你可以设置android:inputType="textPassword"

    方法一:使用setInputType设置(适用于textPassword

    @Override
    public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
    	// TODO Auto-generated method stub
    	if (isChecked) {
    		mPswEdt.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
    				
    	} else {
    		mPswEdt.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    	}
    }

    方法二:使用setTransformationMethod设置(适用于numberPassword

    @Override
    public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
    	// TODO Auto-generated method stub
    	if (isChecked) {
    		mPswEdt.setTransformationMethod(HideReturnsTransformationMethod
    						.getInstance());	
    	} else {			
    		mPswEdt.setTransformationMethod(PasswordTransformationMethod
    						.getInstance());	
    	}
    }


    好了,今天就到这里,希望对大家有所帮助。

    【转载】http://m.blog.csdn.net/blog/benbmw2008/9705305

  • 相关阅读:
    pm2
    php 基础知识
    EBADF, read
    php apache
    noah
    ejs
    node linux
    枚举系统进程
    c++ 进程权限的提升
    Liunx的目录结构
  • 原文地址:https://www.cnblogs.com/jidan/p/3432728.html
Copyright © 2011-2022 走看看