我正在尝试使用 addChangeTextListener,但是当我点击一个键时我的屏幕冻结了。这是代码:
email = (EditText) findViewById(R.id.email);
email.addTextChangedListener(new TextWatcher()
{
@Override
public void afterTextChanged(Editable s)
{
if (email.getText().toString().matches("[a-zA-Z0-9._-]+@[a-z]+\\.+[a-z]+")
&& s.length() > 0)
error.setText("valid email");
else
email.setText("invalid email");
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1,int arg2, int arg3)
{
}
@Override
public void onTextChanged(CharSequence arg0, int arg1,int arg2, int arg3)
{
}
});