设置登录注册页面输入密码时,监听密码显示隐藏;

代码里面;在oncreate()方法里面调用;还需要先定义一个全局变量:private boolean isHidden = true;

private void setchck_password() {
        // 设置第一次输入密码未不可见状态
        login_password.setTransformationMethod(PasswordTransformationMethod
                .getInstance());
        // 设置CheckBox监听
        check_password
                .setOnCheckedChangeListener(new OnCheckedChangeListener() {

                    public void onCheckedChanged(CompoundButton arg0,
                            boolean arg1) {
                        //
                        isHidden = arg1;

                        if (isHidden) {
                            // 设置EditText文本为可见的
                            login_password
                                    .setTransformationMethod(HideReturnsTransformationMethod
                                            .getInstance());
                        } else {
                            // 设置EditText文本为隐藏的
                            login_password
                                    .setTransformationMethod(PasswordTransformationMethod
                                            .getInstance());
                        }
                        isHidden = !isHidden;
                        login_password.postInvalidate();
                        // 切换后将EditText光标置于末尾
                        CharSequence charSequence = login_password.getText();
                        if (charSequence instanceof Spannable) {
                            Spannable spanText = (Spannable) charSequence;
                            Selection.setSelection(spanText,
                                    charSequence.length());
                        }

                    }
                });

    }

在xml里面的布局;

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/logging_image"
    android:orientation="vertical"
    tools:context=".LoggingActivity" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="right" >

        <TextView
            android:id="@+id/back"
            android:layout_width="50px"
            android:layout_height="50px"
            android:layout_margin="20px"
            android:background="@drawable/bns_search_del"
            android:textColor="#fff" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal" >

        <ImageView
            android:id="@+id/image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/icons" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/a"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/image"
        android:layout_margin="40px" >

        <ImageView
            android:id="@+id/image_phone1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/contact_person" />

        <EditText
            android:id="@+id/login_phone"
            android:layout_width="0px"
            android:layout_height="wrap_content"
            android:layout_weight="10"
            android:background="#fff"
            android:hint="请输入手机号"
            android:padding="15px" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/c"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="40px" >

        <ImageView
            android:id="@+id/image_phone2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/contact_person" />

        <EditText
            android:id="@+id/code"
            android:layout_width="0px"
            android:layout_height="wrap_content"
            android:layout_weight="10"
            android:background="#fff"
            android:hint="请输入用户名"
            android:padding="15px" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/b"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="40px" >

        <ImageView
            android:id="@+id/image_phone3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/contact_person" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="10" >

            <EditText
                android:id="@+id/login_password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#fff"
                android:hint="请输入密码"
                android:inputType="textPassword"
                android:padding="15px" />

            <CheckBox
                android:id="@+id/check_password"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:layout_marginRight="15dp"
                android:background="@drawable/logging_checkbox"
                android:button="@null" />
        </RelativeLayout>
    </LinearLayout>

    <Button
        android:id="@+id/login_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="40px"
        android:background="#f90"
        android:text="注册" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20px"
        android:gravity="right"
        android:text="注册即视为同意Help_me《隐私条款》"
        android:textColor="#fff"
        android:textSize="20px" />

</LinearLayout>
时间: 2024-08-12 22:18:46

设置登录注册页面输入密码时,监听密码显示隐藏;的相关文章

unity 登录注册页面数据传递(无数据库)

unity  登录注册页面数据传递(无数据库) 继上一篇随笔.制作unity登录注册页面. 创建一下脚本: 新建脚本"goa"(存储全局变量方便其他脚本的调用): using UnityEngine;using System.Collections; public class goa : MonoBehaviour { //用户名    public const string name = "M_name";    //密码    public const stri

登录注册页面实现

多种登录注册页面实现 前后端语言实现用户注册功能 php注册登录系统 原文地址:https://www.cnblogs.com/knuzy/p/9248539.html

数据库安全检查监听是重点,设置监听密码

Oracle 数据库监听的安全管理是比较容易忽略的一个问题,做一个测试禁用监听的本地验证功能,设置监听密码,数据库版本为11.2.0.4 1.默认配置listener.ora LISTENER =(DESCRIPTION_LIST =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = roidb01)(PORT = 1521))))SID_LIST_LISTENER=(SID_LIST =(SID_DESC =(GLOBAL_DBNAME = orc

路飞项目搭建3 TODO注释, 自定义模态框, vue-cookies操作浏览器cookies, 腾讯云短信开发, 代码(登录注册页面,多方式登录,手机是否存在验证接口,腾讯短信开发)

TODO注释 """ 作用:todo是一种特殊的注释,书写就是 # TODO 注释内容,可以在TODO控制台面板快速定位注释位置 """ 自定义模态框 componses/Login.vue <template> <div class="login"> <span @click="close_login">x</span> </div> </

node.js实现简单的登录注册页面

首先需要新建四个文件 一个服务器js 一个保存数据的txt 一个登陆.一个注册页面html 1.注册页面 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>regist</title> </head> <body> <div> <label for="us

PHP制作登录注册页面

用PHP制作登录和注册页面,一共6个页面,三个可视页面:登录.注册.主页,三个处理页面:验证.添加用户.清除退出 注册 <!--这是注册页面d&z-2-z.php,用户可以提交用户名和密码进行注册,点击注册按钮提交给d&z-4-add.php页面处理--> <!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</ti

javaweb登录注册页面;

初学javaweb,第一个要做的项目就是登陆注册页面,被这两个页面折磨了两天,终于写出来了,相信也会有许多初学者会面临着写这个页面的问题,给大家提供一段代码,仅供参考. 登录页面: <form action="in.jsp" method="post"> <input type="hidden" name="hidden" value="deng"> <table> &l

怎么设置软键盘中Enter的监听

/**布局中必须设置属性<singleLine & imeOptions>*/ <EditText android:id="@+id/edt_searchMicroFilm" android:layout_width="fill_parent" android:layout_height="32dp" android:layout_marginRight="10dp" android:backgrou

linux设置预留端口号,防止监听端口被占用 ip_local_reserved_ports

1. 背景 linux服务器启动时,会对指定的端口进行监听bind,如果同一个机器上这个端口已经被使用,则监听失败,程序无法启动. linux客户端连接服务器accept时,系统会分配本地临时端口用于网络连接. 目前是"大混部"的时代,一台物理机可能会部署多个服务,如果端口号设置不好,很可能会出现端口被其他程序占用的情况. 2. 解决方法 针对我的linux机器看看 本地临时端口配置(2个数: start, end) cat /proc/sys/net/ipv4/ip_local_po