EditText密码:明文和密文

密文:

 public class MainActivity extends Activity {

       private EditText password = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); this.password = (EditText) super.findViewById(R.id.pwdEdittext);
       //设置为密文
MainActivity.this.password.setTransformationMethod(PasswordTransformationMethod.getInstance()); }   @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}

明文密文切换(Checkbox切换):

public class MainActivity extends Activity {

    private EditText password = null;
private CheckBox show = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); this.password = (EditText) super.findViewById(R.id.pwdEdittext);
MainActivity.this.password.setTransformationMethod(PasswordTransformationMethod.getInstance());
this.show = (CheckBox) super.findViewById(R.id.display_checkBox);
this.show.setOnClickListener(new OnclickListenerlmp());
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void register(View view){ Intent intent = new Intent();
intent.setClass(this, RegisterActivity.class);
this.startActivity(intent); }
private class OnclickListenerlmp implements OnClickListener{ @Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(MainActivity.this.show.isChecked()){
//设置为明文显示
MainActivity.this.password.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
}
else{
//设置为密文显示
MainActivity.this.password.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
}
} }

Checkbox二选一

public class RegisterActivity extends Activity {

  private CheckBox choose1 = null;
  private CheckBox choose2 = null;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);   this.choose1 = (CheckBox) super.findViewById(R.id.sex_checkBox1);
  this.choose2 = (CheckBox) super.findViewById(R.id.sex_checkBox2);
  }   @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.register, menu);
    return true;
  }   public void choose(View view){
    if(RegisterActivity.this.choose1.isChecked()){
    choose2.setChecked(false);
   }
    else{
      choose1.setChecked(false);
    }
  }
}

       

Android笔记-5-EditText密码和Checkbox二选一的更多相关文章

  1. Android入门(九):CheckBox多选清单和ScrollView滚动条

    字符串资源文件strings.xml: <resources> <string name="hello">主类main</string> < ...

  2. Android笔记——Android中数据的存储方式(二)

    我们在实际开发中,有的时候需要储存或者备份比较复杂的数据.这些数据的特点是,内容多.结构大,比如短信备份等.我们知道SharedPreferences和Files(文本文件)储存这种数据会非常的没有效 ...

  3. Android笔记二十四.Android基于回调的事件处理机制

        假设说事件监听机制是一种托付式的事件处理,那么回调机制则与之相反,对于基于回调的事件处理模型来说,事件源和事件监听器是统一的,或者说事件监听器全然消失了,当用户在GUI控件上激发某个事件时,控 ...

  4. Android笔记--View绘制流程源码分析(二)

    Android笔记--View绘制流程源码分析二 通过上一篇View绘制流程源码分析一可以知晓整个绘制流程之前,在activity启动过程中: Window的建立(activit.attach生成), ...

  5. Android笔记(四十) Android中的数据存储——SQLite(二) insert

    准备工作: 我们模拟一个注册的页面,先看UI 我们需要创建一个数据库:user,数据库包含表user,user表包含字段id.username.password.mobilephone MainAct ...

  6. Android笔记(二十) Activity中的跳转和值传递

    我们知道,一个APP是由若干个Activity组成的,那么各个Acitivity中肯定需要进行跳转以及传递数值以保证App的运行,现总结一下多个Activity之间的跳转和值传递. 显式Intent跳 ...

  7. android菜鸟学习笔记31----Android使用百度地图API(二)获取地理位置及地图控制器的简单使用

    1.获取当前地理位置: Android中提供了一个LocationManager的类,用于管理地理位置.不能通过构造函数获取该类的实例,而是通过Context的getSystemService(): ...

  8. Android笔记(四十二) Android中的数据存储——SQLite(四)update

    update方法的四个参数: update()方法参数 对应的sql部分 描述 table update table_name 更新的表名 values set column=xxx ContentV ...

  9. Android笔记(二十六) Android中的广播——BroadcastReceiver

    为了方便进行系统级别的消息通知,Android有一套类似广播的消息机制,每个应用程序都可以对自己感兴趣的广播进行注册,这样该程序就只会接收自己所关心的广播内容,这些广播可能是来自于系统,也可能是来自于 ...

随机推荐

  1. 使用git管理代码

    上传工程 1.登录github后,点击右上角带有+号的图标,输入仓库名创建仓库(Repository). 2.在项目文件夹下执行以下命令: touch README.md git init 如果工程中 ...

  2. 2017-2018-1 20155313 《信息安全系统设计基础》 Myod

    2017-2018-1 20155313 <信息安全系统设计基础> Myod Myod要求 1.复习c文件处理内容 2.编写myod.c 用myod XXX实现Linux下od -tx - ...

  3. 20145209刘一阳《JAVA程序设计》第八周课堂测试

    第八周课堂测试 1.下面代码中共有(C)个线程? public class ThreadTest { public static void main(String args[]){ MyThread ...

  4. Oracle数据库的非归档模式迁移到归档模式

    先观察当前的状态: [root@o_target ~]# su - oracle    [oracle@o_target ~]$ sqlplus / as sysdba        SQL*Plus ...

  5. 2555: SubString

    2555: SubString 链接 题意: 动态在末尾加入一个字符串,询问一个字符串出现了多少次. 分析: 如果没有动态加入,那么建出SAM后,求出parent树上,每个点|Right|,然后走一遍 ...

  6. 利用BlockingCollection实现生产者和消费者队列,实现写文本

    最近开发几个小项目,需要把结果写到txt文件里面,并且按照时间进行分文件,由于对于效率要求较高,所以采用 生产者和消费者 模型来进行写出文本,线程中只需要添加队列就立即返回,而不需要等待写文件的时间 ...

  7. mysql mtr写入数据

    BEGIN; --disable_query_log --let $rows= 100 WHILE($rows) { --eval INSERT INTO t1 (a) VALUES ( $rows ...

  8. [PLC]ST语言一:LD_LDI_AND_ANI_OR_ORI

    一:LD_LDI_AND_ANI_OR_ORI基本指令 说明:简单的顺控指令不做其他说明. 控制要求:无 编程梯形图: 结构化编程ST语言: M400:=(M0 OR M1) AND M2; M401 ...

  9. hdu1754 I Hate It(线段树单点更新,区间查询)

    传送门 有更新单个学生成绩和查询某个区间内学生成绩最大值两种操作 线段树代码 #include<bits/stdc++.h> using namespace std; +; using n ...

  10. Python之元类详解

    一.引子 元类属于Python面向对象编程的深层魔法,99%的人都不得要领,一些自以为搞明白元类的人其实也是自圆其说,点到为止,从队元类的控制上来看就破绽百出,逻辑混乱: 二.什么是元类 一切源自于一 ...