Skip to content

Instantly share code, notes, and snippets.

@dominicthomas
Created December 18, 2013 10:21
Show Gist options
  • Save dominicthomas/8020137 to your computer and use it in GitHub Desktop.
Save dominicthomas/8020137 to your computer and use it in GitHub Desktop.
Create a simple positive/negative dialog builder... can be extended by passing in message, yes & no text and callback interfaces....
// pass in values as arguements if required...
private AlertDialog.Builder getSimpleDialogBuilder() {
return new AlertDialog.Builder(this)
.setMessage(getString("Some message here"))
.setCancelable(true)
.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// do something
}
})
.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
}
AlertDialog.Builder myDialog = getSimpleDialogBuilder();
myDialog.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment