问题
Possible Duplicate:
EditText with number keypad by default, but allowing alphabetic characters
Wondering if it is possible to default to a numeric keyboard on focus for an edittext field but also allow users to input characters? None of the input types seem to support this. Thanks!
回答1:
I just tried to add a number text field in Android and it ran in the emulator fine. It defaults to bring up the number pad first, but you can switch to characters just as easy. So try to use a number text field.
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number" />
来源:https://stackoverflow.com/questions/9183260/android-edittext-default-numeric-keyboard-and-allow-text