码迷,mamicode.com
首页 > 移动开发 > 详细

Android 限制只输入某些值包括数字、字母等

时间:2015-07-25 19:57:32      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:限制只输入某些值   数字和字母   android   edittext输入数字和字母   edittext输入字母   

限制只输入某些值包括数字、字母等

android:digits="0123456789abcdefghigklmnopqrstuvwxyz"

上面这行代码可以是你任何的限制,只能输入什么就到里面写就可以了,上面写的是只可以输入数字和字母。

android:inputType="textPassword"
android:digits="0123456789abcdefghigklmnopqrstuvwxyz"
这里是只能输入数字和字母并且是密码格式,这两个设置并没有冲突,android:inputType="textPassword"这里是文本,是可以输入中文的,但是要是你加了android:digits="0123456789abcdefghigklmnopqrstuvwxyz",inputType这里的中文就会失效了,但是password不会失效,这里只是打个比方,大家都懂的。

inputType的属性值

    android:inputType="none"
    android:inputType="text"
    android:inputType="textCapCharacters" 字母大写
    android:inputType="textCapWords" 首字母大写
    android:inputType="textCapSentences" 仅第一个字母大写
    android:inputType="textAutoCorrect" 自动完成
    android:inputType="textAutoComplete" 自动完成
    android:inputType="textMultiLine" 多行输入
    android:inputType="textImeMultiLine" 输入法多行(如果支持)
    android:inputType="textNoSuggestions" 不提示
    android:inputType="textUri" 网址
    android:inputType="textEmailAddress" 电子邮件地址
    android:inputType="textEmailSubject" 邮件主题
    android:inputType="textShortMessage" 短讯
    android:inputType="textLongMessage" 长信息
    android:inputType="textPersonName" 人名
    android:inputType="textPostalAddress" 地址
    android:inputType="textPassword" 密码
    android:inputType="textVisiblePassword" 可见密码
    android:inputType="textWebEditText" 作为网页表单的文本
    android:inputType="textFilter" 文本筛选过滤
    android:inputType="textPhonetic" 拼音输入 //数值类型
    android:inputType="number" 数字
    android:inputType="numberSigned" 带符号数字格式
    android:inputType="numberDecimal" 带小数点的浮点格式
    android:inputType="phone" 拨号键盘
    android:inputType="datetime" 时间日期
    android:inputType="date" 日期键盘
    android:inputType="time" 时间键盘


版权声明:本文为博主原创文章,未经博主允许不得转载。

Android 限制只输入某些值包括数字、字母等

标签:限制只输入某些值   数字和字母   android   edittext输入数字和字母   edittext输入字母   

原文地址:http://blog.csdn.net/pcaxb/article/details/47058957

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!