1DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
2 @Override
3 public void onClick(DialogInterface dialog, int which) {
4 switch (which){
5 case DialogInterface.BUTTON_POSITIVE:
6 //Yes button clicked
7 break;
8
9 case DialogInterface.BUTTON_NEGATIVE:
10 //No button clicked
11 break;
12 }
13 }
14};
15
16AlertDialog.Builder builder = new AlertDialog.Builder(context);
17builder.setMessage("Are you sure?").setPositiveButton("Yes", dialogClickListener)
18 .setNegativeButton("No", dialogClickListener).show();
19