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. Mysql(压缩包)下载与安装

    第一步:百度搜索  MySQL 点击官网进入 或者复制链接进入下载页面:https://downloads.mysql.com/archives/community/    第二步:选择自己需要的  ...

  2. Verilog_Day2

    Verilog_Day1 在CSDN博客上.http://blog.csdn.net/m0_38073085 第三章: 书上基本知识 每个Verilog程序包括4个主要部分:端口定义,I/O说明,内部 ...

  3. zookeeper入门实例

    package org.merit.test.zookeepertest; import java.io.IOException;import java.util.List;import java.u ...

  4. 20145234黄斐《网络对抗技术》实验九、Web安全基础实践

    PS:我是分了两次做的这次试验,第二次实验的时候电脑出了一点问题熄火了……原本后面的是有图的结果博客没保存图没了…… WebGoat WebGoat是由著名的OWASP负责维护的一个漏洞百出的J2EE ...

  5. JavaScript总结(一)

    什么是JavaScript? 首先我们要知道它是什么?JavaScript是一门专门用来对网页进行编程的脚本语言:因为我是学习Java之后再来学习JavaScript的,所以我的第一疑问JavaScr ...

  6. 如何启动 EDB*Plus

    磨砺技术珠矶,践行数据之道,追求卓越价值 回到上一级页面: PostgreSQL基础知识与基本操作索引页     回到顶级页面:PostgreSQL索引页 由于EnterpriseDB公司的网站上讲的 ...

  7. c++ 创建二叉树

    #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> ...

  8. 一维码ITF 25简介及其解码实现(zxing-cpp)

    一维码ITF 25又称交插25条码,常用在序号,外箱编号等应用.交插25码是一种条和空都表示信息的条码,交插25码有两种单元宽度,每一个条码字符由五个单元组成,其中二个宽单元,三个窄单元.在一个交插2 ...

  9. 【HNOI2013】比赛

    题面 题解 \(n \leq 9 \to\)爆搜 对每一场的结果进行搜索,最后进行\(\mathrm{check}\) 然后会发现没有什么分 搜索最重要的就是剪枝 接下来就列出一些剪枝 搜索时,强制每 ...

  10. springmvc 使用jq传递json数据时出现415错误

    出现415错误是因为解析json时出现了错误,通过排查几点就能解决. 样例: <script> function requestByJson() { var datatest = {&qu ...