您可以禁用键盘上的某些键以防止用户输入错误的字符吗?
答案 0 :(得分:0)
以下代码用于禁用数字和字符
{
final InputFilter filter = new InputFilter() {
@Override
public CharSequence filter(CharSequence source,
int start, int end, Spanned dest, int dstart,
int dend)
{
for (int i = start; i < end; i++)
{
if (Character.isDigit(source.charAt(i))||Character.isLetter(source.charAt(i)))
{
return "";
}
}
return null;
}
};
answerTXT.setFilters(new InputFilter[]{filter});
}