on pressing positive button why dialogbox is closed?
<p>Actually i'm checking some values in my dialog box if they are not valid i don't want to dismiss my dialog box.unfortunately by default When i press submit button my dialog box gets shut down :( how i can escape ???</p>

<pre><code>LayoutInflater factory = LayoutInflater.from(EmailJavaAPI.this);
final View textEntryView = factory.inflate(R.layout.usrpwsdialog,null);
((EditText)textEntryView.findViewById(R.id.etxtUserName)).setText((((EditText)findViewById(R.id.editTextFrom)).getText()).toString());

final EditText usrName = (EditText)textEntryView.findViewById(R.id.etxtUserName);
final EditText usrPws = (EditText)textEntryView.findViewById(R.id.etxtPws);

//AlertDialog alert=new AlertDialog(EmailJavaAPI.this);


return new AlertDialog.Builder(EmailJavaAPI.this)
    .setTitle(R.string.kpsdomain)
    .setView(textEntryView)
    .setPositiveButton(R.string.dgbtnsubmit,
        new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog,
                int whichButton) {
                      userName = usrName.getText().toString().trim();
                      userPws = usrPws.getText().toString().trim();
                      ((EditText)findViewById(R.id.editTextFrom)).setText(userName);

                      if(userName.equals("")){
                              textEntryView.findViewById(R.id.txtVWRUserName).setVisibility(View.VISIBLE);
                      }
                                      if(userPws.equals("")){
                                          textEntryView.findViewById(R.id.txtVWRPws).setVisibility(View.VISIBLE);
                                      }
                                      if(!userName.equals("")&amp;&amp; !userPws.equals("")){
                                          Toast.makeText(EmailJavaAPI.this, "User Name and Password has been set up", Toast.LENGTH_SHORT).show();
                                      }
                                      else{
                                          //***IMPORTANT***
                                          //Dialog Should be opened if this condition is true
                                      }
                                }
                            })
                    .setNegativeButton(R.string.dgbtnDiscard,
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog,
                                        int whichButton) {
                                    dialog.dismiss();
                                }
                            }).create();
</code></pre>
