问题
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