实现目标:

实现原理:

为CheckBox添加一个监听器事件;

实现的源码:

package edu.cquptzx.showPassword;

import android.app.Activity;

import android.os.Bundle;

import android.text.method.HideReturnsTransformationMethod;

import android.text.method.PasswordTransformationMethod;

import android.widget.CheckBox;

import android.widget.CompoundButton;

import android.widget.EditText;

publicclass ShowPasswordActivity extends Activity {

private EditText edittext;

private CheckBox checkbox;

/** Called when the activity is first created. */

publicvoid onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

/*find the object by IDs .*/

edittext = (EditText) findViewById(R.id.et);

checkbox = (CheckBox) findViewById(R.id.cb);

/* add a listener to the CheckBox */

checkbox.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener()

{

publicvoid onCheckedChanged(CompoundButton buttonView,boolean isChecked)

{

if(checkbox.isChecked())

{

/* show the password*/

edittext.setTransformationMethod(HideReturnsTransformationMethod.getInstance());

}

else

{

/* hide the password */

edittext.setTransformationMethod(PasswordTransformationMethod.getInstance());

}

}

});

}

}

相关知识:

最后实现效果:

打勾显示输入的密码 --EditText与setTransformationMethod的更多相关文章

  1. Android_EditText 打勾显示输入的密码 --EditText与setTransformationMethod

    实现目标: 实现原理: 为CheckBox添加一个监听器事件; 实现的源码: package edu.cquptzx.showPassword; import android.app.Activity ...

  2. Android 打勾显示输入的密码

    main.xml: <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:and ...

  3. Android学习笔记之打钩显示输入的密码

    利用EditText作为密码输入框是个不错的选择(只需设置输入类型为textPassword即可),保密且无需担心被盗取.但有时用户也不知道自己输入的是否正确,这时就应该提供一个“显示密码”的复选框, ...

  4. python getpass模块:隐藏不显示输入的密码

    不知道为什么,本机测试必须要在debug模式下才正常运行.. import getpass #用于隐藏用户输入的字符串,常用来接收密码 def checkuser(user,passwd): ': r ...

  5. WordPress登录框显示/隐藏输入的密码

    直接让用户自行根据需要选择是全部隐藏输入的密码,还是全部显示输入的密码. 在全部显示密码框的内容时,用户输错的可能性就大大降低,这也是微软推荐的一种密码框处理方式.效果如下: 今天,我将给大家介绍,在 ...

  6. 解决首次访问jenkins,输入默认密码之后,一直卡住问题

    简介   安装系统:centos6.5 安装方式:在官网中下载jenkins.war,放到tomcat根目录下的webapps中,启动tomcat(还有一种yum在线安装的方式) 1.首次访问,出现如 ...

  7. Android中EditText显示明文与密码的两种方式

    效果图如下所述: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:and ...

  8. python作业设计:输入用户名密码,认证成功后显示欢迎信息,输错三次后锁定

    作业需求: 1.输入用户名密码 2.认证成功后显示欢迎信息 3.输错三次后锁定实现思路: 1.判断用户是否在黑名单,如果在黑名单提示账号锁定. 2.判断用户是否存在,如果不存在提示账号不存在. 3.判 ...

  9. EditText 显示明文和密码

    1.效果图 2.布局文件 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xml ...

随机推荐

  1. 08_linux下安装chrome

    首先下载chrome,需要改hosts哦(o(^▽^)o,别告诉我你不会,可以问度娘.谷哥哦) 下载地址:https://dl.google.com/linux/direct/google-chrom ...

  2. ajax+XMLHttpRequest里的FormData实现图片异步上传

    发这篇博客的时候我是自己在研究这个XMLHttpRequest请求,在别人的博客上面知道XMLHttpRequest新加了一个FormData的东西,好像现在APP请求后台也有用这种方式的吧. 别的不 ...

  3. 在win8.1 64位环境下有关Oracle的安装和卸载

    1,Oracle安装 3 注意:在win8.1环境下安装64位的oracle客户端,注意配置是1g的 2.Oracle的卸载:http://jingyan.baidu.com/article/f7ff ...

  4. allegro 的光绘层概念

    TOP层: board geometry/outline  manufacturing/photoplot_outline                  etch/top              ...

  5. Android Service之LOCATION_SERVICE

    Android提供了GPS功能 LocationManager obj = (LocationManager)getSystemService(Context.LOCATION_SERVICE) Pe ...

  6. 三个QT咨询公司以及QT5.0的主要特点

    三个咨询公司(他们也贡献代码):http://www.kdab.com/http://v-play.net/http://www.ics.com/qt 一个论坛:http://forum.qt.io/ ...

  7. 14.1.3 检查InnoDB 可用性:

    14.1.3 Checking InnoDB Availability 14.1.3 检查InnoDB 可用性: 确定是否你的server 支持InnoDB: 1.执行命令 SHOW ENGINES; ...

  8. 【转】ubuntu打包压缩命令总结

    原文网址:http://blog.csdn.net/renero/article/details/6428523 .tar解包:tar xvf FileName.tar打包:tar cvf FileN ...

  9. 【转】Android的权限permission

    原文网址:http://blog.csdn.net/nei504293736/article/details/6974599 <uses-permission android:name=&quo ...

  10. 什么是Web Service?

    Web service到底是什么:在什么情况下你应该使用Web service. 分布式应用程序和浏览器 研究一下当前的应用程序开发,你会发现一个绝对的倾向:人们开始偏爱基于浏览器的瘦客户应用程序.这 ...