title: editText field is required before moving on to another Activity
body: <p>I have validation for <code>editText</code>. If the <code>editText</code> field is empty it should fail validation and stop the user moving on to another <code>Activity</code>, as a value is required. How to do it? I know this is a basic question, but I can't figure out how to do this.</p>
  
  <p>My code:</p>
  
  <pre><code>btninsert = (Button)findViewById(R.id.btn_insert);
  btninsert.setOnClickListener( new View.OnClickListener() {
      public void onClick(View v) {
          insertValues();
          EditText userName = (EditText) findViewById(R.id.editText1);
  
          if( userName.getText().toString().length() == 0 )
              userName.setError( "First name is required!" );
  
          Intent i = new Intent(getApplicationContext(), Login.class);
          startActivity(i);
      }
  });
  </code></pre>
  
  <p>When this <code>Button</code>  is clicked the user is redirect to next screen, but I need that if validation fails they stay on the current <code>Activity</code>, and only when validation is successful (i.e. a value has been entered) they go to the next <code>Activity</code>. </p>