您的位置:首页 > 移动开发 > Android开发

Android每日范例——密码输入框

2015-10-10 21:05 423 查看
密码输入框的使用方法
在XML布局中添加EditText控件,使用EditText控件的属性进行限定

未限定代码:
android:password值为true或者false,表示当前为输入密码框,即输入的字符是不可见的

[code]    <EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint = "请输入用户名"/>

    <EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:password="true"
        android:hint="请输入密码"/>


限定代码:
有时候会对密码长度进行限制,或者对密码的输入类型进行限定

[code]    <EditText 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:maxLength="10"
        android:numeric="integer"
        android:password="true"
        android:hint="请输入密码"/>


android:numeric表示对输入的类型进行限制

android:maxLength表示的输入的最长字符长度


EditText还有许多的限定方式,例如maxLines等等,需要的可以自己查询一下
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: