AlertDialog that informs of error but keep activity current
<p>I am trying to do some EditText validation and want to use an AlertDialog
when the user inputs something that is illegal.</p>

<p>How can I have an alert dialog pop up and tell the user what is wrong with the input
and then after "OK" is pressed just go back to the same view?  </p>

<p>I'm waiting until a "confirm" button is pressed to do validation and am already inside 
a button's onClickListener in an Activity like so:</p>

<pre><code>protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.add_progress);
    //
    // user adds info to progress screen
    // clicks confirm when done
    //
Button confirmButton = (Button) findViewById(R.id.confirm); 
    confirmButton.setOnClickListener(new View.OnClickListener() {

    public void onClick(View view) {
          // do validation code here
          //
          AlertDialog alert = new AlertDialog.Builder(AddStudentProgress.this).create();
          alert.setTitle("Oops");
          alert.setMessage("Inputs Can't be Empty");
          alert.setButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // I reall want to go back to the Activity and not really do anything
                }});

          if ( (mScoreText.getText().toString().equals("") )) {
            alert.show();
          }
          else {
            // validation looks ok, continue
          }
</code></pre>

<p>Am I going about this the wrong way? What should I be doing of I want to validate input?</p>

<p>Thanks in advance,
Martin</p>
