How do I default to numeric keyboard on EditText without forcing numeric input? [duplicate] How do I default to numeric keyboard on EditText without forcing numeric input? [duplicate] android android

How do I default to numeric keyboard on EditText without forcing numeric input? [duplicate]


Add the following line of code, and it will do the trick :)

editText.setRawInputType(Configuration.KEYBOARD_QWERTY);

This will show the the numeric keypad first, but also allows you to enter free text.

More information here.


This may be device dependant but have you tried:

 android:inputType="phone"

All Input Types Link

in the EditText's xml , this gives you the number pad keyboard but then you can still switch to letter's if you want. (Atleast on my Nexus One).


Note that: setRawInputType(InputType.TYPE_CLASS_NUMBER);

has the desired effect on some devices but not others...

On htc it works fine however on galaxy tab II you only get the numeric keyboard and no way to switch back to alpha.