EditText 限制只能输入字母和数字,并且字母自动大写
来源:互联网 发布:软件中的冒烟测试 编辑:程序博客网 时间:2024/06/05 02:33
原创文章,如有转载,请注明出处:http://blog.csdn.net/myth13141314/article/details/78124068
限制EditText的输入类型需要设置digits属性
<EditText android:id="@+id/tv_code" style="@style/edt_text" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginLeft="4dp" android:layout_weight="1" android:hint="请输入" android:maxLength="17" android:digits="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/>
以上设置以后就只能输入数字和大小写的字母了
要将输入的小写字母自动转化为大写字母并显示在EditText上,比较简便的方法是设置EditText的setTransformationMethod
//首先是小写转大写的方法public class UpperCaseTransform extends ReplacementTransformationMethod { @Override protected char[] getOriginal() { char[] aa = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; return aa; } @Override protected char[] getReplacement() { char[] cc = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}; return cc; }}//然后是设置editText.setTransformationMethod(new UpperCaseTransform());
通过以上设置以后,用户键盘输入小写字母,EditText会转化成大写显示
阅读全文
0 0
- EditText 限制只能输入字母和数字,并且字母自动大写
- Edittext 限制只能输入数字和字母
- 限制EditText只能输入数字和字母
- 设置EditText只能输入数字和字母
- 设置EditText只能输入字母和数字
- js限制只能输入字母和数字!
- ios 限制只能输入字母和数字
- ios 限制只能输入字母和数字
- ios 限制只能输入字母和数字
- ios 限制只能输入字母和数字
- Android EditText输入限制最大字符长度 和 限制只能输入数字和字母(包含大小写)
- 限制EditText只输入数字和字母
- EditText设置输入的类型,比如说限制只能输入字母和数字
- UITextFiled限制输入字母并且输入的字母大写
- EditText限制只能输入汉字字母和空格
- android 只能输入数字和字母并且弹出数字键盘
- android 只能输入数字和字母并且弹出数字键盘
- EditText 输入字母自动转换为大写
- 【FAQ】Word组件Spire.Doc 技术FAQ汇总 | 附下载
- 2017西安网络赛 E. Maximum Flow F. Trig Function 组合数
- nova 对instance的start instance 操作的log
- [leetcode] 437. Path Sum III
- 按天分表后查询分页(查询表计算方法)
- EditText 限制只能输入字母和数字,并且字母自动大写
- TimesTen JMS/XLA 实现 Trigger 功能
- Scribe日志收集系统介绍
- redis cluster和redis sentinel的一些文章
- linux时间同步ntp服务的安装与配置
- 有关http和WebSocket 的区别
- Android项目小集
- Android Studio修改包名及问题
- PO、VO、BO、DTO、POJO、DAO、DO之间的关系