Created
August 29, 2016 13:09
-
-
Save bangiqi/1feb5df4ba4f1c171bbc87984ca79d0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//declare diatas method | |
//variable global | |
final Context context = this; | |
================================================================= | |
//simpan dalam method | |
// set title | |
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); | |
alertDialogBuilder.setTitle("Perhatian!"); | |
// set dialog message | |
alertDialogBuilder | |
.setMessage("Apakah anda ingin keluar dari aplikasi ini?") | |
.setCancelable(true) | |
.setNegativeButton("Batal", new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
//MenuActivity.this.finish(); | |
dialog.dismiss(); | |
} | |
}) | |
.setPositiveButton("Keluar",new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog,int id) { | |
// if this button is clicked, close | |
// current activity | |
finish(); | |
System.exit(0); | |
//MainActivity.this.finish(); | |
} | |
}); | |
// create alert dialog | |
AlertDialog alertDialog = alertDialogBuilder.create(); | |
// show it | |
alertDialog.show(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment