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
  • 5,944
  • 5
  • 34
  • 50

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,819
  • 2
  • 20
  • 29
0

Put this on your layout:

android:digits="abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ,0123456789"

Those will be the only allowed symbols.

g00dy
  • 6,752
  • 2
  • 29
  • 42
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
  • 901
  • 2
  • 14
  • 26