EditText常用属性【一】:空白提示/文本域/特殊字符/数字类型/等属性设置
来源:互联网 发布:mac能玩穿越火线吗 编辑:程序博客网 时间:2024/05/20 20:20
先看效果:
代码:
- <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
- <TextView
- android:id="@+id/tip1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="1.设置一个空白提示文本: android:hint=www.wirelessqa.com; " />
- <TextView
- android:id="@+id/tip2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/tip1"
- android:text="2.设置只允许输入长度不超过4个的字符: android:maxLength=4;" />
- <EditText
- android:id="@+id/edit_tip"
- android:layout_width="fill_parent"
- android:layout_height="40dp"
- android:layout_below="@+id/tip2"
- android:hint="www.wirelessqa.com"
- android:maxLength="4" />
- <TextView
- android:id="@+id/tip3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/edit_tip"
- android:text="3.设置空白提示文本的颜色:android:textColorHint=#FF0000; " />
- <EditText
- android:id="@+id/edit_tip2"
- android:layout_width="fill_parent"
- android:layout_height="40dp"
- android:layout_below="@+id/tip3"
- android:hint="www.wirelessqa.com"
- android:textColorHint="#FF0000" />
- <TextView
- android:id="@+id/tip4"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/edit_tip2"
- android:text="4.设置edittext为不可用: android:enabled=false " />
- <EditText
- android:id="@+id/edit_tip3"
- android:layout_width="fill_parent"
- android:layout_height="40dp"
- android:layout_below="@+id/tip4"
- android:enabled="false"
- android:hint="www.wirelessqa.com"
- android:textColorHint="#EEB422" />
- <TextView
- android:id="@+id/tip5"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/edit_tip3"
- android:text="5.设置edittext为不可编缉: android:editable=false " />
- <EditText
- android:id="@+id/edit_tip4"
- android:layout_width="fill_parent"
- android:layout_height="40dp"
- android:layout_below="@+id/tip5"
- android:editable="false"
- android:hint="www.wirelessqa.com"
- android:textColorHint="#EEB422" />
- <TextView
- android:id="@+id/tip6"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/edit_tip4"
- android:text="6.设置edittext为文本域" />
- <EditText
- android:id="@+id/edit_tip5"
- android:layout_width="fill_parent"
- android:layout_height="100dp"
- android:layout_below="@+id/tip6" />
- <TextView
- android:id="@+id/tip7"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/edit_tip5"
- android:text="7.设置输入特殊字符 - 密码: android:password=true" />
- <EditText
- android:id="@+id/edit_tip6"
- android:layout_width="fill_parent"
- android:layout_height="40dp"
- android:layout_below="@+id/tip7"
- android:password="true" />
- <TextView
- android:id="@+id/tip8"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/edit_tip6"
- android:text="8.设置输入特殊字符 - 电话号码: android:phoneNumber=true" />
- <EditText
- android:id="@+id/edit_tip7"
- android:layout_width="fill_parent"
- android:layout_height="40dp"
- android:layout_below="@+id/tip8"
- android:phoneNumber="true" />
- <TextView
- android:id="@+id/t9"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/edit_tip7"
- android:text="9.设置输入数字类型 - integer(正整数): android:numeric=integer" />
- <EditText
- android:id="@+id/e9"
- android:layout_width="fill_parent"
- android:layout_height="40dp"
- android:layout_below="@+id/t9"
- android:numeric="integer" />
- <TextView
- android:id="@+id/t10"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/e9"
- android:text="10.设置输入数字类型 - isigned(带符号整数): android:numeric=signed" />
- <EditText
- android:id="@+id/e10"
- android:layout_width="fill_parent"
- android:layout_height="40dp"
- android:layout_below="@+id/t10"
- android:numeric="signed" />
- <TextView
- android:id="@+id/t11"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/e10"
- android:text="11.设置输入数字类型 - decimal(浮点数): android:numeric=decimal" />
- <EditText
- android:id="@+id/e11"
- android:layout_width="fill_parent"
- android:layout_height="40dp"
- android:layout_below="@+id/t11"
- android:numeric="decimal" />
- </RelativeLayout>
- </ScrollView>
本文链接: 【Android常用控件】EditText常用属性【一】:空白提示/文本域/特殊字符/数字类型/等属性设置
转载声明:本站文章若无特别说明,皆为原创,转载请注明来源:WirelessQA,谢谢!^^
补充edittext中文api文档:http://www.cnblogs.com/over140/archive/2010/09/02/1815439.html
0 0
- EditText常用属性【一】:空白提示/文本域/特殊字符/数字类型/等属性设置
- 【Android常用控件】EditText常用属性【一】:空白提示/文本域/特殊字符/数字类型/等属性设置
- EditText常用属性【二】:为文本输入框指定软键盘类型和软键盘回车键图标设置
- EditText特殊属性小结
- EditText特殊属性
- 【Android常用控件】EditText常用属性【二】:为文本输入框指定软键盘类型和软键盘回车键图标设置
- 【Android常用控件】EditText常用属性【二】:为文本输入框指定软键盘类型和软键盘回车键图标设置
- HTML5 placeholder(空白提示) 属性
- EditText常用属性
- EditText不常用属性
- EditText常用属性
- EditText常用属性
- EditText常用属性
- EditText的常用属性
- EditText常用属性
- [android] edittext常用属性:
- EditText常用属性
- EditText常用属性
- 【12c新特性】12c中如何自动启动PDB Pluggable Database
- Redis基础
- 1013
- 服务端判断苹果内容是否支付完成(二)
- Oracle存储过程基本语法介绍-存储过程
- EditText常用属性【一】:空白提示/文本域/特殊字符/数字类型/等属性设置
- 欢迎使用CSDN-markdown编辑器
- Android volley 使用OkHttp3.0
- 使用第三方授权登录以及分享文字和图片
- 页面checkbox处理
- HR筛选简历的12个要点,投简历必读!
- JavaScript笔记4--闭包
- 汉诺塔(三)
- EditText常用属性【三】:EditText选取操作