当前位置: 代码迷 >> Android >> Android 限制只输入某些值包括数目字、字母等
  详细解决方案

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

热度:61   发布时间:2016-04-27 23:48:16.0
Android 限制只输入某些值包括数字、字母等

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

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" 时间键盘


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

  相关解决方案