Unfortunately this is not possible, because only one inputType can be set for an EditText. The following will just show alphabatic characters on buttons.
However, what I can suggest you is, set your input type to numeric, and just add a small switchKeyboard button on your form close to the numpad. And set its onClick
t = (EditText) findViewById(R.id.test);
t.setKeyListener(new KeyListener() {
@Override
public boolean onKeyUp(View view, Editable text, int keyCode, KeyEvent event) {
return false;
}
@Override
public boolean onKeyOther(View view, Editable text, KeyEvent event) {
return false;
}
@Override
public boolean onKeyDown(View view, Editable text, int keyCode, KeyEvent event) {
if (keyCode == 67) { // Handle backspace button =)
if (text.length() > 0) {
t.setText(text.subSequence(0, text.length() - 1));
t.setSelection(text.length()-1);
}
}
return false;
}
@Override
public int getInputType() {
return InputType.TYPE_CLASS_NUMBER;
}
@Override
public void clearMetaKeyState(View view, Editable content, int states) {
}
});
In this case you type is number and android will show numeric keyboard, but you can input whatever you want.
Also you can override other methods as you wish.
Asus tablet has that feature, they have customized the default keyboard. And the keyboard contains the numbers and alphabets only. I think your requirement solution is too to customize the default keyboard
This is not possible given current default Android input types across various phones.
There are many possible hacks that work on some keyboards but not on others, like the common method of setting the raw input type that is commonly included in answers:
Best advice I could find is to use the textPostalAddress input type in your XML:
android:inputType="textPostalAddress"
Unfortunately this doesn't do what we want it to do yet, but maybe it will in the future. The only advantage of this is that the meta information on your edit box will reflect what you intend.