Only show number buttons on Soft Keyboard in Android?
You must only add this line on your code:
input.setRawInputType(Configuration.KEYBOARD_12KEY);
this will show only the numeric keyboard.
android:inputType="phone"
android:digits="1234567890"
is an option
The accepted answer did not work for me (tested on OnePlus 3t and Samsung Galaxy S6/S7 phones).
This solution uses numberPassword but overrides the default transformation method for the EditText to show characters instead of showing dots.
<EditText
android:id="@+id/userid"
android:inputType="numberPassword"
android:maxLength="6"
/>
// Numeric 6 character user id
EditText input = findViewById(R.id.userid);
// Process input and show characters instead of dots
input.setTransformationMethod(SingleLineTransformationMethod.getInstance());
The phone number pad is the closest thing I've found (set inputType="phone"
on your EditText
).