Advertisement
Guest User

Untitled

a guest
May 26th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. @Override
  2.     public void onBackPressed() {
  3.  
  4.         final AlertDialog.Builder aleartdialog;
  5.  
  6.         aleartdialog = new AlertDialog.Builder(MainActivity.this);
  7.         aleartdialog.setIcon(R.drawable.check_symbol);
  8.         aleartdialog.setTitle(R.string.exit_text);
  9.         aleartdialog.setCancelable(false);
  10.  
  11.         aleartdialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
  12.             @Override
  13.             public void onClick(DialogInterface dialog, int which) {
  14.                 finish();
  15.             }
  16.         });
  17.         aleartdialog.setNegativeButton("No", new DialogInterface.OnClickListener() {
  18.             @Override
  19.             public void onClick(DialogInterface dialog, int which) {
  20.                 dialog.cancel();
  21.             }
  22.         });
  23.  
  24.         AlertDialog alertDialog = aleartdialog.create();
  25.         aleartdialog.show();
  26.  
  27.  
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement