2

I have a login

If user don't enter username or password and press "login" button, the EditText hint will warn you, like thislogin(turn red). How can I implement this?

2 Answers2

3

I think you should set error instead

editText.setError(getString(R.string.error_required));

but if you want that

editText.setHint()
editText.setHintTextColor
Andy Weinstein
  • 2,639
  • 3
  • 21
  • 32
Hossam elsawy
  • 86
  • 1
  • 6
1

Based on the image you have posted , it is very simple to show that hint when there is no data entered in username/password fields.

if(username.isEmpty())
{
  usernameEditTextView.setHint("please enter username");
  usernameEditTextView.setHintTextColor(R.color.Red);
}
Ravi
  • 881
  • 1
  • 9
  • 23