zoukankan      html  css  js  c++  java
  • 设置登录注册页面输入密码时,监听密码显示隐藏;

    代码里面;在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>
  • 相关阅读:
    java+selenium+new——同一个标签窗口里 ,访问多个网页的后退driver.navigate().back()、前进driver.navigate().forward()、刷新driver.navigate().refresh()等功能 。以及获取当前页面的title属性driver.getTitle()和获取当前页面的url地址driver.getCurrentUrl()
    SoapUI接口测试——关联——参数化
    SoapUI接口测试——添加测试套件——new TestSuite——(类似于postman里面的集合)——添加测试步骤——teststeps(测试步骤)
    java+selenium+new——获取网页源代码driver.getPageSource()
    g++命令行详解
    hdoj_1503Advanced Fruits
    指针遍历vector向量
    最长公共子序列
    hdoj_1087Super Jumping! Jumping! Jumping!
    pcc32应用1
  • 原文地址:https://www.cnblogs.com/zhengyanyan/p/5497471.html
Copyright © 2011-2022 走看看