Skip to content

Instantly share code, notes, and snippets.

@matthewmorrone
Created November 12, 2019 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewmorrone/8bf426931c88dda832e492bcea275eae to your computer and use it in GitHub Desktop.
Save matthewmorrone/8bf426931c88dda832e492bcea275eae to your computer and use it in GitHub Desktop.
show alert dialog from anywhere
new AlertDialog.Builder(getActivity())
.setTitle(getString(R.string.dialog_title))
.setMessage(getString(R.string.dialog_text))
.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// OK clicked
}
})
.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// CANCEL clicked
}
}).show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment