i have written the below code to display the AlertDialogBox as follows
private void dispAlertBox(final String title,final String message,final String ok,final String cancel){
final AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
try{
alertbox.setMessage(message);
alertbox.setTitle(title);
alertbox.setPositiveButton(ok,new DialogInterface.OnClickListener(){
public void onClick(DialogInterface arg0, int arg1){
}
});
alertbox.setNegativeButton(cancel,new DialogInterface.OnClickListener(){
public void onClick(DialogInterface arg0, int arg1){
}
});
alertbox.show();
}catch(Exception e){
//Handle BadTokenException.
}
}
In the above i would like to close the AlertDialog whenever i click on the ok and also cancel.So if we click on the any other area other than AlertDialog(ok and cancel) it should not close.It is working fine in 2.x versions of Android.But in Android 4.0 the dialog is getting closed even if we click on the empty space other than ok and cancel button.How can i overcome this.
Thanks&Regards,
Venkat.
Try adding
before showing it.