I'm trying to choose correct inputType in my adress dialog streetNumber field. I want to show numeric keyboard first, but then let user also to input alphabetic characters for some very special cases. Closer to this is inputType datetime, but this doesn't allow to enter alphabetic characters. So how to set my streetNumber field correctly?
Asked
Active
Viewed 1.0k times
7
-
There are lots of answers to this on many related posts, but unfortunately *it is not currently possible* using `inputType` or `setRawInputType()` if you want your code to work on "most devices" – Richard Le Mesurier Nov 25 '15 at 05:49
-
Possible duplicate of [EditText with number keypad by default, but allowing alphabetic characters](http://stackoverflow.com/questions/3544214/edittext-with-number-keypad-by-default-but-allowing-alphabetic-characters) – Richard Le Mesurier Nov 25 '15 at 05:51
3 Answers
5
Use android:inputType="textPostalAddress"

Dharmendra
- 33,296
- 22
- 86
- 129
-
Your postal address contains number as well as text so best option for address is android:inputType="textPostalAddress" but if you don't want a text keyboard then you can set only number keyboard – Dharmendra Jul 26 '11 at 10:00
-
1so have can I set showing number keyboard first with combination with inputType:textPostalAddress? – Janci Jul 26 '11 at 10:04
-
You can not use keyboard with combination you have only one choice if you want to use both text and number in postal address or you can use android:inputType="text" – Dharmendra Jul 26 '11 at 10:10
0
The EditText
inherits from TextView
and shares its input type attributes with it. They can be found here in the official documentation.
Maybe the input type textPostalAddress
would be suitable for your need. If not, plenty of other types are available. The XML attribute that allows setting this type is android:inputType="the type you have chosen"
.

Shlublu
- 10,917
- 4
- 51
- 70
-
1that's the problem I went through all type and couldn't find nothing that exactly match my requests – Janci Jul 26 '11 at 09:59
-3
See if this can help you
myEditText.setRawInputType(Configuration.KEYBOARD_QWERTY)

Umesh
- 4,406
- 2
- 25
- 37
-
-
This works on both my samsung galaxy and moto droid. It does not, however work on Galaxy Tab. Still haven't figured it out why? – Umesh Jul 26 '11 at 10:10
-
oh I just tryed it on Galaxy Tab, and this can't be used, we have to probably find something else... – Janci Jul 26 '11 at 11:58
-
-
This "works" because the value of Configuration.KEYBOARD_QWERTY is 2, which is the value of inputType.numberDecimal. I was expecting postalAddress input type to first show number input, then after the space show characters. But it doesn't work. – Diederik Jan 18 '13 at 13:54