Я хочу проверить электронную почту, введенную внутри EditText, и этот код, который у меня уже есть:
final EditText textMessage = (EditText) findViewById (R.id.textMessage);
final TextView text = (TextView) findViewById (R.id.text);
textMessage.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
if (textMessage.getText().toString().matches("[a-zA-Z0-9._-][email protected][a-z]+.[a-z]+") && s.length() > 0)
{
text.setText("valid email");
}
else
{
text.setText("invalid email");
}
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
public void onTextChanged(CharSequence s, int start, int before, int count) {}
});
Проблема в том, что когда я вводил 3 символа после "@", появляется сообщение "действительный адрес электронной почты", когда оно должно появляться, когда я представляю полное письмо.
Любое отклонение?
Спасибо всем!