block characters ë,à,é,ä etc from keypad in android

148 views Asked by At

is there a way to block characters like ä which appear on long press of keys like a,e,i etc in android using input filter.

1

There are 1 answers

1
Vijaya Varma Lanke On

Hope it will help you

private EditText editText;
private String characterSet = "give_blocking_charset_here";

private InputFilter filter = new InputFilter() {

    @Override
    public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {

        if (source != null && characterSet.contains(("" + source))) {
            return "";
        }
        return null;
    }
};

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    editText = (EditText) findViewById(R.id.editText);
    editText.setFilters(new InputFilter[] { filter });
}