If password field not filled it should not make link to next activity & show alert. How can i do that?
<p>My code:</p>

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

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 LinkingPage extends Activity {

     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(LinkingPage.this,LinkingPage.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) {
                 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);

                 }

                  else
                  {Intent obj = new Intent(LinkingPage.this,ResourcePage.class);
                  obj.putExtra("name", name.getText().toString());                                          
                  obj.putExtra("pass", pass.getText().toString());
                      startActivity(obj);
                  }
           }
        });


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

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

                 return builder.create();
            }
        }

        return null;
    }

}
</code></pre>

<p>When both fields are kept empty, and button is clicked alert is generated. Same happens when only name field is filled. But when name field is kept empty and passwor is filled , then though an alert is generated but link to other page is also generated showing my password.How can i prevent this??</p>
