title: (Android) Enable button only when all login fields are not giving an error
body: <p>been looking for a previous answer for this but can't seem to find an android version of it... </p>
  
  <p>I'm making a login page for an app, and I've got 3 input fields (First name, last name, email) and a text watcher to tell the user if there's an error in their input ((e.g. nothing there/too long/not a valid email). I'm trying to make the log in button disabled until no errors are showing, but I can't seem to sort it. I'm very new to android, just been working from scraps of tutorials here and there really... I've tried setting a boolean for each input value that sets to false when the input is bad/true when it's acceptable, and something to check if all 3 are true or not to enable/disable the button but that doesn't seem to work... </p>
  
  <p>In the emulator, the button doesn't disable at all and I've got warnings that the booleans I made are always true even though I've given instances to make them false, and defined them as false at the start...</p>
  
  <p>Here's my java class at the moment:</p>
  
  <pre><code>public class Login extends Activity implements OnClickListener, TextWatcher {
      EditText firstName;
      EditText lastName;
      EditText eMail;
      ImageButton Begin;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_login);
          initialiseUI();
      }
  
      private void initialiseUI() {
  
          eMail = (EditText)findViewById(R.id.edit_email);
          eMail.addTextChangedListener(this);
  
          firstName= (EditText)findViewById(R.id.edit_firstname);
          firstName.addTextChangedListener(this);
  
          lastName= (EditText)findViewById(R.id.edit_surname);
          lastName.addTextChangedListener(this);
  
          Begin= (ImageButton) findViewById(R.id.Beginbutton);
          Begin.setOnClickListener(this);
      }
  
      boolean name=false;
      boolean surname=false;
      boolean email=false;
  
      boolean isEmailValid(CharSequence eMail) {
          return android.util.Patterns.EMAIL_ADDRESS.matcher(eMail)
                  .matches();
      }
  
      public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
      public void onTextChanged(CharSequence s, int start, int before, int count) {}
      public void afterTextChanged(Editable s) {
          Is_Valid_Email(eMail);
          Is_Valid_Name(firstName);
          Is_Valid_Surname(lastName);
          Is_Login_Valid();
      }
  
      public void Is_Valid_Name(EditText firstName) {
          if (firstName.getText().toString().trim().isEmpty()){
              firstName.setError("Enter Name");
              name=false;}
          else if (firstName.getText().toString().length()&gt;20){
              firstName.setError("Name too long!");
              name=false;}
          else if (firstName.getText().toString().length()&gt;1){
              firstName.setError(null);
              name=true;}
      }
  
      public void Is_Valid_Surname(EditText lastName){
          if (lastName.getText().toString().trim().equalsIgnoreCase("")){
              lastName.setError("Enter Surname");
              surname=false;}
          else if (lastName.getText().toString().length()&gt;20){
              lastName.setError("Surname too long!");
              surname=false;}
          else if (lastName.getText().toString().length()&gt;1){
              lastName.setError(null);
              surname=true;}
      }
  
      public void Is_Valid_Email(EditText eMail) {
          if (eMail.getText().toString().trim().equalsIgnoreCase("")) {
              eMail.setError("Enter e-mail");
              email=false;}
          else if (!isEmailValid(eMail.getText().toString())) {
              eMail.setError("Invalid Email Address");
              email=false;}
          else if (isEmailValid(eMail.getText().toString())) {
              email=true;}
          }
  
      public void Is_Login_Valid() {
          if (name=true){
              if (surname=true){
                  if (email=true){
                      Begin.setEnabled(true);
                  }
                  else if (email=false){
                      Begin.setEnabled(false);
                  }
              }
              else if(surname=false){
                  Begin.setEnabled(false);
              }
          }
          else if (name=false){
              Begin.setEnabled(false);
          }
      }
  
      /** Called when the user clicks the Login button */
          public void onClick(View v)  {
              Intent intent = new Intent(Login.this, question_1.class);
              startActivity(intent);
          }
  }
  </code></pre>