登录注册那些事儿(二)
来源:互联网 发布:雪梨淘宝店衣服质量 编辑:程序博客网 时间:2024/05/22 16:54
输入密码的显隐藏
效果图:
① 最简单的显隐藏:
先在xml中设定edit 输入类型android:inputType="textPassword"
if(isChecked){
//如果选中,显示密码
editText.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
}else{
//否则隐藏密码
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
②显示之后3s隐藏
//显隐藏操作
showOrHintPws.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mHandler.removeMessages(1); if (showPwdText) { password_edit_text.setTransformationMethod(PasswordTransformationMethod.getInstance()); password_edit_text.setSelection(password_edit_text.getText().toString().length()); showOrHintPws.setBackgroundResource(R.mipmap.login_icon_eyeclose); } else { showOrHintPws.setBackgroundResource(R.mipmap.login_icon_eye); password_edit_text.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); password_edit_text.setSelection(password_edit_text.getText().toString().length());//设置光标移动到最后一位 Message msg = new Message(); msg.what = 1; mHandler.sendMessageDelayed(msg, 3000); } showPwdText = !showPwdText; }});
private Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what) { case 1: password_edit_text.
setTransformationMethod(PasswordTransformationMethod.getInstance()); password_edit_text.setSelection(password_edit_text.getText().toString().length()); showOrHintPws.setBackgroundResource(R.mipmap.login_icon_eyeclose); showPwdText = false; mHandler.removeMessages(0); break; default: break; } } };
阅读全文
0 0
- 登录注册那些事儿(二)
- 登录注册那些事儿(一)
- 登录注册那些事儿(三)
- 敏捷那些事儿(二)
- Ext2那些事儿(二)
- iTween那些事儿(二)
- SQL那些事儿(二)
- 嵌入式开发的那些事儿(二)
- Servlet&JSP的那些事儿(二)
- OpenCV安装那些事儿(二)
- 学生信息管理系统 那些事儿(二)
- 苹果开发者账号那些事儿(二)
- 操作系统那些事儿(二)-Linux
- Servlet&JSP的那些事儿(二)
- 苹果开发者账号那些事儿(二)
- 关于C++的那些事儿(二)
- Android单元测试那些事儿(二)
- 编程的那些事儿(二)
- 二分查找(非递归)
- 几个基础的小程序
- 最长回文
- hdu 5685 Problem A (逆元)
- 如何禁止极速版迅雷thunderplatform.exe启动
- 登录注册那些事儿(二)
- 六数码 关于EOF
- 顺序表
- Error:Could not run build action using Gradle installation解决办法
- Online Hard Example Mining
- 1-3 beanstalkd参数
- vue2.x 中如何获取 DOM
- Leetcode 368 Largest Divisible Subset
- 链表