[英]Making an EditText object accept only numeric values
I'd like to create programatically an EditText within this attribute: 我想以编程方式在此属性内创建一个EditText:
android:inputType="number|numberSigned|numberDecimal"
In brief I'd like it to accept only numeric values. 简而言之,我希望它仅接受数字值。 How do I have to set my EditText object? 我该如何设置EditText对象?
The corresponding method for inputType is inputType的相应方法是
public void setInputType (int type) 公共无效setInputType(整数类型)
So something like the below should work (untested) 所以像下面这样的东西应该工作(未经测试)
setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.