Why can't I enter more inputs after entering bigger than 1 in InputFIlter?

40 Views Asked by At

I used InputFilter to filter my inputs. It's changing input filter with button press to Binary to Octal that part is working perfectly. The Question is, I cannot input values after entering higher values. (Like 2 in binary and 8 in octal). InputFilter works perfectly until I enter expected values(0-1 in Bin, 0-7 in Oct). But I cannot input any value to the EditText after entering other value(3, to binary). I Tested on physical devices.(Xiaomi and Huawei)

et=findViewById(R.id.et);
    et.setFilters(new InputFilter[] {
            new InputFilter() {
                @Override
                public CharSequence filter(CharSequence cs, int start,
                                           int end, Spanned spanned, int dStart, int dEnd) {
                    // TODO Auto-generated method stub
                    if(cs.equals("")){ 
                        return cs;
                    }
                    if(cs.toString().matches("[0-1 ]")){
                        return cs;
                    }
                    return "";
                }
            }
    });
0

There are 0 best solutions below