微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

[Androrid]笔记9-用户友好的输入界面

对于一个用户友好的输入界面而言,接受用户输入的文本框内认会提示用户如何输入;当前用户把焦点切换到输入框时,输入框自动选中其中已输入的内容,避免用户删除已有内容;当用户把焦点切换到只接受电话号码时,输入法自动切换到键盘

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:androrid="http://schemas.android.com/apk/res/android"
    androrid:layout_width="match_parent"
    androrid:layout_height="match_parent"
    androrid:stretchColumns="1"
    >
    <TableRow>
    <TextView
        androrid:layout_width="match_parent"
        androrid:layout_height="wrap_content"
        androrid:text="用户名"
        androrid:textSize="16sp"
        />
        <EditText
            androrid:layout_width="match_parent"
            androrid:layout_height="wrap_content"
            androrid:hint="请填写登录账号"
            androrid:selectAllOnFocus="true"
            />
    </TableRow>
    <TableRow>
        <TextView
            androrid:layout_width="match_parent"
            androrid:layout_height="wrap_content"
            androrid:text="密码"
            androrid:textSize="16sp"
            />
        <!--只能接受数字密码-->
        <EditText
            androrid:layout_width="match_parent"
            androrid:layout_height="wrap_content"
            androrid:inputType="numberPassword"
            />
    </TableRow>
    <TableRow>
        <TextView
            androrid:layout_width="match_parent"
            androrid:layout_height="wrap_content"
            androrid:text="年龄"
            androrid:textSize="16sp"
            />
        <!--inputType="number"表明只能输入数值-->
        <EditText
            androrid:layout_width="match_parent"
            androrid:layout_height="wrap_content"
            androrid:inputType="number"
            />
    </TableRow>
    <TableRow>
        <TextView
            androrid:layout_width="match_parent"
            androrid:layout_height="wrap_content"
            androrid:text="生日"
            androrid:textSize="16sp"
            />
        <!--inputType="date"表明日期输入框-->
        <EditText
            androrid:layout_width="match_parent"
            androrid:layout_height="wrap_content"
            androrid:inputType="date"
            />
    </TableRow>
    <TableRow>
        <TextView
            androrid:layout_width="match_parent"
            androrid:layout_height="wrap_content"
            androrid:hint="请填写您的电话号码"
            androrid:text="电话号码"
            androrid:textSize="16sp"
            />
        <!--inputType="phone"表明只能输入数值-->
        <EditText
            androrid:layout_width="match_parent"
            androrid:layout_height="wrap_content"
            androrid:selectAllOnFocus="true"
            androrid:inputType="phone"
            />
    </TableRow>
    <Button
        androrid:layout_width="wrap_content"
        androrid:layout_height="wrap_content"
        androrid:text="注册"
        />
</TableLayout>

这里写图片描述

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐