当前位置: 代码迷 >> Android >> 如何用正则表达式使edittext只能输入若干位数字或检查editview输入的内容
  详细解决方案

如何用正则表达式使edittext只能输入若干位数字或检查editview输入的内容

热度:71   发布时间:2016-05-01 21:28:25.0
怎么用正则表达式使edittext只能输入若干位数字或检查editview输入的内容?
如题

------解决方案--------------------
在XML里面设置就可以了
<EditText android:layout_width="100px"
android:layout_height="wrap_content"
android:numeric="integer"
android:maxLength="3"/>
------解决方案--------------------
android:digits=""
这个属性,你填什么进去,你的输入框里面就只能输入那几个
android:digits="123"
比如你填123,那么输入1、2、3之外的东西,都不会显示上去,
长度就用android:maxLength="3"