任务二 用户注册界面设计

(1)EditText控件详解

编辑框使用EditText表示,作用是在屏幕上显示文本输入框。编辑框可以输入单行文本,也可以输入多行文本,还可以指定是的文本(如密码、电话号码、日期等)。编辑框的基本语法格式如下。

<EditText

        属性列表

/>

XML属 性                                                                                    

  android: hint

为空时显示的文字提示信息,可通过textColorHint设置提示信息的颜色

android:inputType

设置文本的类型,用于帮助输入法显示合适的键盘类型。有如下值设置:none、text、textCapCharacters字母大小、textCapWords单词首字母大小、textAutoComplete自动完成、phone电话号码、datetime时间日期、date日期、time时间等

android:password

以小点.显示文本

android:phoneNumber

设置为电话号码的输入方式

(2)文字填空题(1 分)

//在空白处填入适当代码,使编辑框为空时默认显示“Hello World”。

<EditText

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        android:textColor="#DDDDDD"

        _________________

        android:id ="@+id/et"

        android:maxLength = "10"

/ ></EditText/ >            ANSWER:android:hint="Hello World"

(3)Button按钮用法

按钮使用Button表示,作用是在屏幕上显示一个按钮。按钮的基本语法格式如下。

<Button

        属性列表

/>

(4)文字填空题(1 分)

在空白处填入适当代码,使按钮显示文字“点击”。

<Button

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"

        ______________

></Button>       ANSWER:android:text="点击"

(5)实战代码、视频、截图

5.1界面编程实战1:实战视频

5.2相应XMl代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

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

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="注册新用户"
            android:gravity="center_horizontal"
            android:textSize="12pt"
            android:textStyle="bold"
            />
    </LinearLayout>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="用户名:"
        android:textSize="10pt"/>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请填写登陆账号"
        android:selectAllOnFocus="true"
        android:id="@+id/editText" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="密码:"
        android:textSize="10pt"
        />
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:password="true"
        />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="电话号码:"
        android:textSize="10pt"
        />
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请填写您的电话号码"
        android:phoneNumber="true"
        android:selectAllOnFocus="true"
        />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="出生日期:"
        android:textSize="10pt"
        />
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请填写你的出生日期"
        android:inputType="date"
        android:selectAllOnFocus="true"
        />

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

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="注 册"
            />
    </LinearLayout>
</LinearLayout>

<!--author CYJ 2018-01-22 -->

(6)源码链接

往期链接:<Android界面编程>  任务一   酱油诗词赏析 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

云炬学长

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值