2
我有一个EditText字段供用户以磅为单位输入自己的体重。我如何覆盖传统键盘并改为显示数字小键盘?如何在EditText视图的焦点上默认使用数字键盘?
我有一个EditText字段供用户以磅为单位输入自己的体重。我如何覆盖传统键盘并改为显示数字小键盘?如何在EditText视图的焦点上默认使用数字键盘?
这并没有为我工作的。不过,我可以通过以下任一种方法完成上述操作:
// TYPE_CLASS_NUMBER: Class for numeric text. This displays the numbers/symbols keyboard.
editText.setInputType(InputType.TYPE_CLASS_NUMBER);
// TYPE_CLASS_PHONE: Class for a phone number. This displays the phone number keypad.
editText.setInputType(InputType.TYPE_CLASS_PHONE);
这就是我脱下了谷歌API
//Set the input style to numbers, rather than qwerty keyboard style.
txtView.setInputMethod(DigitsInputMethod.getInstance());