title: Android: Validation symbol in EditText
body: <p>We have the <code>setError</code> method for setting an error message with a red exclamation symbol at the end of the box if validation of an EditText returns false:</p>
  
  <p><a href="https://i.stack.imgur.com/vwsQ8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vwsQ8.png" alt="validation returned false"></a></p>
  
  <p>I want to set a <strong>green tick symbol</strong>, just like the red exclamation at the end of the box when my validation returns true:</p>
  
  <pre><code>password.setOnFocusChangeListener(new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View v, boolean hasFocus) {
              if (!hasFocus) {
  
                  if (password.getText().toString().length() &lt; 6) {
                      password.setError("Password should be greater than 6 characters!");
                  }
                  else {
                      //validation is true, so what to put here?
                  }
              }
          }
      });
  }
  </code></pre>
  
  <p><strong>EDIT 1</strong>
  Seemingly impossible, but there's more to the problem. I did this:</p>
  
  <pre><code>email.setOnFocusChangeListener(new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View v, boolean hasFocus) {
              if (!hasFocus) {
                  String mail = email.getText().toString();
                  if(!android.util.Patterns.EMAIL_ADDRESS.matcher(mail).matches()) {
                      email.setError("Please enter a valid email address");
                  } 
                  else {
                      Log.i("yay!","Email is valid!!!");
                      email.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.validated, 0);
                  }
              }
          }
      });
  </code></pre>
  
  <p>Though I can see in my logs that <code>yay: Email is valid!!!</code>, I can't see the validation symbol at the end of the <code>EditText</code>.</p>
  
  <p>However, to my surprise when I change the <code>if</code> statement to always <code>false</code>, I can see both the symbol with the log statement.</p>
  
  <p>Any explanations upon why could this be happening?</p>