做一个EditText对象只接受数字值 [英] Making an EditText object accept only numeric values
本文介绍了做一个EditText对象只接受数字值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想这个属性在编程方式创建一个EditText:
I'd like to create programatically an EditText within this attribute:
android:inputType="number|numberSigned|numberDecimal"
在简短的我想它仅接受数值。我如何必须设置我的EditText对象?
In brief I'd like it to accept only numeric values. How do I have to set my EditText object?
推荐答案
有关inputType下相应的方法是
The corresponding method for inputType is
因此,像下面的应工作(未经测试)
So something like the below should work (untested)
setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL )
这篇关于做一个EditText对象只接受数字值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文