2

I have an EditText box and I want the default keyboard that should come up when it is selected to be the alphabetic keypad, since most of the time users will be entering alphabetic characters.

However, I also want to allow users to enter numbers too, if they need to. Using android:inputType="text" restricts input to characters only. What options do I have?

Neil Townsend
  • 6,024
  • 5
  • 35
  • 52

3 Answers3

0

android:inputType="text" was not supposed to block numbers to be inserted, anyway, you can always use the "|".

Take a look at the docs. http://developer.android.com/reference/android/widget/TextView.html#attr_android:inputType

Pozzo Apps
  • 1,859
  • 2
  • 22
  • 32
0

Put this on your layout:

android:digits="abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ,0123456789"

Those will be the only allowed symbols.

g00dy
  • 6,752
  • 2
  • 30
  • 43
0

Use this code in layout:

 android:digits="@string/edittextDigit"

and string.xml

 <string name="edittextDigit">qwertzuiopasdfghjklyxcvbnmQWERTZUIOPASDFGHJKLYXCVBNM</string>

So, users can enter characters specified by you.

realuser
  • 931
  • 2
  • 15
  • 26