1

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?

enter image description here

Haresh Chhelana
  • 24,720
  • 5
  • 57
  • 67
ibrahimyilmaz
  • 18,331
  • 13
  • 61
  • 80
  • 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 Answers2

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
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