How do I show the number keyboard on an EditText in android?
To do it in a Java file:
EditText input = new EditText(this);input.setInputType(InputType.TYPE_CLASS_NUMBER);
I found this implementation useful, shows a better keyboard and limits input chars.
<EditText android:inputType="phone" android:digits="1234567890" .../>
Additionally, you could use android:maxLength
to limit the max amount of numbers.
To do this programmatically:
editText.setInputType(InputType.TYPE_CLASS_PHONE);KeyListener keyListener = DigitsKeyListener.getInstance("1234567890");editText.setKeyListener(keyListener);