EditTextcontent_text= (EditText) findViewById(R.id.edit_content_change);
if (title.equals(CommonConfig.TEACHER_AGE)){
InputFilter[] filters = new InputFilter[]{new InputFilter.LengthFilter(2)};//限制其只能输入2个字符
LogUitls.showToast(this,"教龄");
content_text.setKeyListener(new NumberKeyListener() {
protected char[] getAcceptedChars()
{
char[] numberChars=getResources().getString(R.string.numbers).toCharArray();
return new char[]{'1','2','3','4','5','6','7','8','9','.','0'}; //限制其只能输入数字
}
@Override
public int getInputType() {
return InputType.TYPE_CLASS_NUMBER; //返回数字键盘
}
}
);
content_text.setFilters(filters); //给EditText添加限制
if (title.equals(CommonConfig.TEACHER_AGE)){
InputFilter[] filters = new InputFilter[]{new InputFilter.LengthFilter(2)};//限制其只能输入2个字符
LogUitls.showToast(this,"教龄");
content_text.setKeyListener(new NumberKeyListener() {
protected char[] getAcceptedChars()
{
char[] numberChars=getResources().getString(R.string.numbers).toCharArray();
return new char[]{'1','2','3','4','5','6','7','8','9','.','0'}; //限制其只能输入数字
}
@Override
public int getInputType() {
return InputType.TYPE_CLASS_NUMBER; //返回数字键盘
}
}
);
content_text.setFilters(filters); //给EditText添加限制