EditText用于接收软键盘输入的文字,由文本视图派生而来,拥有TextView已有的各种属性和方法。还有以下的属性:
inputType:指定输入的文本类型。若同时使用多种文本类型,则可使用 | 把多种文本类型拼接起来。
maxLength:指定文本允许输入的最大长度。
hint:指定提示文本的内容。
textColorHint:指定提示文本的颜色。
inputType输入类型有:
案例:
<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="5dp"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="下面是登录信息" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:maxLength="10" android:hint="请输入用户名" android:inputType="text" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:maxLength="10" android:hint="请输入密码" android:inputType="textPassword" />