Phone numbers soft keyboard only

I would like to have a soft phone keypad that allows you to enter ONLY numbers.

I can achieve "single numbers" with inputType = "number" (where the soft keyboard is by default, but allows only numbers to be input as input) and phone style with inputType = "phone". But when combined as a phone number, even if the style is telephone, the soft keyboard allows the use of characters other than numbers.

I want a phone-like style, because the BIGGER numeric buttons and are easier to press, and I only need to enter numbers.

Any suggestions besides creating a custom keyboard?

+5
source share
1 answer

You can force the keyboard to use a numeric value when you set the input type directly, not sure if it has additional buttons

EditText t = (EditText) findViewById(R.id.edittext1);

t.setRawInputType(Configuration.KEYBOARD_12KEY);

or

t.setRawInputType(InputType.TYPE_CLASS_PHONE);

I used the first one quite a while ago and it worked, but not sure about the latest versions of Android.

But you cannot influence the layout. Their keyboard is provided by the current application that makes the keyboard, it can do whatever it wants. Even things like giving you two buttons that let the user enter Morse code, for example https://play.google.com/store/apps/details?id=org.emergent.android.morseime .

If this is the keyboard that you get, this is not something you want to implement yourself - the relatively simple layout with 10 buttons does not work so much.

+5
source

All Articles