Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created March 6, 2019 00:29
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/3e9a9d3550ef03dc3d97507d0885f675 to your computer and use it in GitHub Desktop.
Save parzibyte/3e9a9d3550ef03dc3d97507d0885f675 to your computer and use it in GitHub Desktop.
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("Opciones");
builder.setItems(OPCIONES_ALERTA, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// which representa el índice del arreglo de opciones
String eleccion = OPCIONES_ALERTA[which].toString();
// Aquí puedes mostrar la elección o hacer lo que sea con ella.
Toast.makeText(getActivity(), "Elegiste: " + eleccion, Toast.LENGTH_SHORT).show();
// En el click se descarta el diálogo
dialog.dismiss();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment