I want to display seperate alerts for name and pass fields
<p>Here is my code:</p>

<pre><code>package com.example.userpage;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class UserPage extends Activity {
     AlertDialog.Builder builder;
    private final static int EMPTY_TEXT_ALERT = 0;

        @Override
        public Dialog onCreateDialog(int id) {
            switch(id) {
                case EMPTY_TEXT_ALERT: {
                builder = new AlertDialog.Builder(this);
                    builder.setMessage("Message:Fields Empty!!!")
                           .setPositiveButton("OK", new DialogInterface.OnClickListener() {

                               @Override
                               public void onClick(DialogInterface dialog, int which) {
                                   dialog.cancel();
                               }

                     });

                     return builder.create();
                }
            }

            return null;
        }



     String tv,tv1;
    EditText name,pass;
     TextView x,y;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
         Button button = (Button) findViewById(R.id.widget44);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

                Intent obj = new Intent(UserPage.this,UserPage.class);
                startActivity(obj);

            }
        });

        x = (TextView) findViewById(R.id.widget46);
        y = (TextView) findViewById(R.id.widget47);
         name = (EditText)findViewById(R.id.widget41);
         pass = (EditText)findViewById(R.id.widget43);
        Button button1 = (Button) findViewById(R.id.widget45);
        button1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

              //tv= name.getText().toString();
               //tv1 = pass.getText().toString();
               x.setText(tv);
               y.setText(tv1);
               tv = name.getText().toString();
               if(tv.trim().equals("")) {
                   // text is empty


                   showDialog(EMPTY_TEXT_ALERT);


               }
               tv1 = pass.getText().toString();
              if (tv1.trim().equals(""))
               {

                   showDialog(EMPTY_TEXT_ALERT);

               }
           }
        });


    }
   }
</code></pre>
