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.
Asked
Active
Viewed 133 times
0
-
https://stackoverflow.com/questions/20635704/detect-and-count-special-characters-in-edittext-android – Ashvin solanki Oct 03 '18 at 11:18
-
https://stackoverflow.com/a/21828520/3627279 – Joe Oct 03 '18 at 11:43
1 Answers
0
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 });
}

Vijaya Varma Lanke
- 603
- 2
- 7
- 19
-
I am hoping for a more generic answer as I cant add or dont know all character types which appear on long press of a key and also if I use the above for character set like "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ", if i type "aa" it will be rendered as blank. – Tenzin Younten Taktsak Oct 05 '18 at 10:36