Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Last active August 2, 2019 17:26
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 parzibyte/fa87f5a8a9cf6dcf8864ed511be6eba5 to your computer and use it in GitHub Desktop.
Save parzibyte/fa87f5a8a9cf6dcf8864ed511be6eba5 to your computer and use it in GitHub Desktop.
AlertDialog dialogo = new AlertDialog
.Builder(MainActivity.this) // NombreDeTuActividad.this, o getActivity() si es dentro de un fragmento
.setPositiveButton("Sí, eliminar", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Hicieron click en el botón positivo, así que la acción está confirmada
}
})
.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Hicieron click en el botón negativo, no confirmaron
// Simplemente descartamos el diálogo
dialog.dismiss();
}
})
.setTitle("Confirmar") // El título
.setMessage("¿Deseas eliminar Compra de galletas?") // El mensaje
.create();// No olvides llamar a Create, ¡pues eso crea el AlertDialog!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment