Use it accordingly
AlertDialog.Builder alertbox = new AlertDialog.Builder(YourActivity.this);
alertbox.setTitle("Do you want To exit ?");
alertbox.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
// finish used for destroyed activity
exit();
}
});
alertbox.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
// Nothing will be happened when clicked on no button
// of Dialog
}
});
alertbox.show();
0
solved Alert dialog with button throws exception