2

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?

Community
  • 1
  • 1
dimika
  • 131
  • 2
  • 9

2 Answers2

3

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.

bschultz
  • 4,244
  • 1
  • 25
  • 33
  • Can you help me? How can I implement it for my way? – dimika Jan 24 '12 at 05:51
  • Hmm. You could always put a button by the EditText to act as a switch for [ABC] keypad or [123]. Set the inputType based on whether they're switching from [ABC] to [123] and vice versa. Just think of the best logical way you can implement it in your application that would make it easy for the user to utilize. – bschultz Jan 24 '12 at 19:24
0

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.

Vic Vuci
  • 6,993
  • 6
  • 55
  • 90
  • You're wrong. From SDK: android:inputType="number" A numeric only field. Corresponds to TYPE_CLASS_NUMBER | TYPE_NUMBER_VARIATION_NORMAL. – dimika Jan 23 '12 at 21:32
  • Did you try it? I mean it pops up with the alternative characters, which has the numbers. I just tested it myself and it worked fine, maybe you should be more clear on what you're asking for. – Vic Vuci Jan 23 '12 at 21:34
  • Yes I try it on galaxy tab (Android 3.1). Only digits are available. – dimika Jan 23 '12 at 21:49
  • Ahh you should have mentioned this was for a tablet. I'll look into it. – Vic Vuci Jan 23 '12 at 21:50