Jorge B. Jorge B. - 6 months ago 86
Android Question

EditText view with keyboard number only

I want a keyboard with ONLY visible numbers to an EditText view. Without any other character.

I have tested with all available inputs and don't work.
I have searched a way to get a keyboard only with numbers but I have only seen references to:

android: inputType = "numberPassword"

But I want visible numbers in EditText.
Someone can help me?

I want a keyboard like that: (numberPassword)

enter image description here

I have tried with:




and appears like that:

enter image description here


After several tries, I got it! I'm setting the keyboard values programmatically like that


Or if you want you go with the XML view is like:

android: inputType = "numberPassword"

Both configs gonna display a password bullets, and as far as we are looking display numbers on the EditText we need to create a custom ClickableSpan class.

 private class NumericKeyBoardTransformationMethod extends PasswordTransformationMethod {
    public CharSequence getTransformation(CharSequence source, View view) {
        return source;

And finally we need implementing it to the EditText in order to display the characters typed.

myEditText.setTransformationMethod(new NumericKeyBoardTransformationMethod());

This is how my keyboard looks like now