嗨,我正在使用文本监视器编辑文本我想限制长度
之后的数字suppose i want restrict length for 3
It should not allow 1234
but it should allow 123.(except dot(.) it should not allow any other character)
如何使用texttwatcher
还尝试限制除点以外的所有键项,但不工作
insideEdit.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == 46) // dot key code is 46
{
return false;
}else {
return true;
}
}
});
使用
android:maxLength="4"
inside <EditText
tag