EditText编辑框

EditText是Android中用于接收用户输入的组件,继承自TextView。它可以设置inputType来限定输入的文本类型,如文本、密码等。maxLength属性限制最大输入长度,hint提供输入提示,textColorHint定义提示文本颜色。示例展示了创建用户名和密码输入框的布局代码。
摘要由CSDN通过智能技术生成

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" />

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

当当2000

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

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

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

打赏作者

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

抵扣说明:

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

余额充值