Numeric keyboard as default [duplicate]

落花浮王杯 提交于 2019-12-11 02:17:21

问题


Possible Duplicate:
EditText with number keypad by default, but allowing alphabetic characters

I have an EditText where user can enter both numbers (0 - 9) and characters (a -z, what ever). But I would like to set the numeric soft-keyboard as default. I want the numeric keyboard appearing first, but user can press the [ABC] button and enter what ever character he wants.

Is this possible?


回答1:


As far as I know, if you use inputType="phone" / inputType="number" you cannot switch back to the text keyboard. This is not exclusive to tablets or any specific version of the Android OS.

A workaround would be to change it programmatically using setInputType. You would have to implement it in a way that best suits your application.




回答2:


You can change the EditText to include:

android:inputType="phone"

Which is only the numpad

or

android:inputType="number"

Which also allows characters, but starts on the number keyboard.



来源:https://stackoverflow.com/questions/8978627/numeric-keyboard-as-default

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!