[:zh]<界面编程>任务二 用户注册界面设计[:]2018-01-24

2021/10/18 17:10:13

本文主要是介绍[:zh]<界面编程>任务二 用户注册界面设计[:]2018-01-24,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

(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)源码链接

往期链接:  任务一   酱油诗词赏析" href="http://blog.csdn.net/qq_39154376/article/details/79121689" rel="external nofollow" target="_blank"><Android界面编程>  任务一   酱油诗词赏析 



这篇关于[:zh]<界面编程>任务二 用户注册界面设计[:]2018-01-24的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程