I want to disable some of buttons in typed area. for example I want to disable 1,2,3 buttons in keyboard. I want to learn is it possible or not?
Asked
Active
Viewed 279 times
1
-
you can override the event related to that button, for example [overriding back button](http://stackoverflow.com/questions/3141996/android-how-to-override-the-back-button-so-it-doesnt-finish-my-activity) – Pararth Jun 10 '14 at 12:17
-
How can I override keyboard input type? – ibrahimyilmaz Jun 10 '14 at 12:18
-
1. [Handling Keyboard Actions](https://developer.android.com/training/keyboard-input/commands.html) and 2. [Overriding Android Native Keyboard](http://stackoverflow.com/questions/17758751/overriding-android-native-keyboard) – Pararth Jun 10 '14 at 12:20
2 Answers
0
You can use following code in your xml
<EditText
android:inputType="text"
android:digits="0,4,5,6,7,8,9
/>

Pankaj Deshpande
- 502
- 2
- 5
- 15
-
Still I can click the other buttons I want to see them disabled. – ibrahimyilmaz Jun 10 '14 at 12:27
0
You can use following code either on java side
private List<Char> allowedChars = new ArrayList(Char);
allowedChars.add(...);
allowedChars.add(...);
allowedChars.add(...);
allowedChars.add(...);
InputFilter filter = new InputFilter() {
public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend) {
for (int i = start; i < end; i++) {
// Your condition here
if (!allowedChars.contains(source.charAt(i)))) {
return "";
}
}
return null;
}
};
edit.setFilters(new InputFilter[]{filter});

Pankaj Deshpande
- 502
- 2
- 5
- 15