I have put a boolean condition inside a Alertdialog "OK" button..but that condition doesn't seem to be working..on top of that..even after commenting dialog.dismiss()..the alert dialog still gets dismissed when i used for some checking..
this is the alert dialog small code..
ab.setCancelable(false).setPositiveButton("Add", new DialogInterface.OnClickListener() {
   @Override
   public void onClick(DialogInterface dialog, int which) {
       if(ValidationsForNewCelebration()){
           str1=et1.getText().toString();
           str2=et2.getText().toString();
           //  AddNewTask anct=new AddNewTask();
           //  anct.execute();
           //  dialog.dismiss();
       } else {
       }     
   }
}
and this my boolean conditional code..
protected boolean ValidationsForBlankFields(){
    boolean allFieldsValid=true;
    if(et1.getText().toString().length()<=0){
        Toast.makeText(StartingActivity.this, "Field should not be kept Blank ", Toast.LENGTH_SHORT).show();         
        //return false;
        allFieldsValid=false;
    }
    else if(et2.getText().toString().length()<=0){
         Toast.makeText(StartingActivity.this, "Field should not be kept Blank ", Toast.LENGTH_SHORT).show();
        //return false;
        allFieldsValid=false;
    }
    else if(tv1.getText().toString().length()<=0){
         Toast.makeText(StartingActivity.this, "Please fill up the Blank Field", Toast.LENGTH_SHORT).show();
         allFieldsValid=false;
    }
    else if(tv2.getText().toString().length()<=0){
         Toast.makeText(StartingActivity.this, "Please fill up the Blank Field", Toast.LENGTH_SHORT).show();
         allFieldsValid=false;
    }
    if(!allFieldsValid){
          return false;
    } else {
          return true;
    }
} 
tv1,*tv2* are two textviews while et1 and et2 are edittext. Condition is to check whether they are empty or not.
 
     
    