How do I set up a soft EditText keyboard to use numbers at the beginning, but still allow text?

I want users to enter a zip code into my application. A common use case is the US zip code, which consists entirely of numbers, so I would like to first display the numeric keypad on soft input. However, not all postal codes are exclusively numbers, so I still need to allow users to enter other characters.

I tried to do this using android:inputType , but by setting the "number" flag, it automatically blocks any input except for numbers. Is there a way to just accept the general text, but get a soft keyboard to initially display the keyboard based on numbers?

+6
android
source share
1 answer

Have you tried first setting the inputType parameter to "number", and then through TextWatcher, changing the input type of the TextView programmatically?

0
source share

All Articles