有没有一种方法可以使用输入过滤器阻止android中长按a,e,i等键时出现的ä等字符。
答案 0 :(得分:0)
希望对您有帮助
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 });
}