功能
EditText用来输入或者编辑文本内容。比较重要的属性有:
- inputType,输入类型,例如text(文本)、textPassword(密码)、number(整数)、date(日期)、time(时间)、datetime(日期时间)
- maxLength,文本最大长度
- hint,提示内容
显示文本框
代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="4dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="请输入姓名"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:hint="请输入密码"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:hint="请输入身份证号"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="date"
android:hint="请输入出生日期"/>
</LinearLayout>
效果: