Last active
November 11, 2018 05:07
-
-
Save girish3/4709a2097c6128ce1a8ca3740c5878d6 to your computer and use it in GitHub Desktop.
[Alert Dialog] Alert dialog is created using a builder pattern #android_snippet #android
This file contains hidden or 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
// this is a context | |
AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
// Check other builder methods like setCancelable, setIcon.. | |
builder.setTitle("Set Title"); | |
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int id) { | |
// do something | |
} | |
}); | |
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int id) { | |
// do something | |
} | |
}); | |
AlertDialog dialog = builder.create(); | |
dialog.show(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment