Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在这个属性中以编程方式创建一个 EditText:
android:inputType="number|numberSigned|numberDecimal"
简而言之,我希望它只接受数值。如何设置我的 EditText 对象?
inputType 对应的方法是
公共无效 setInputType (int 类型)
所以像下面这样的东西应该可以工作(未经测试)
setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL )