Last active
August 29, 2015 14:15
-
-
Save roboxito/f101083f3a98beb5e7a6 to your computer and use it in GitHub Desktop.
Android AlertDialog Fragment Example
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
MensajeDialogo dlg=new MensajeDialogo(); | |
dlg.setMensaje("Contenido del diálogo."; | |
dlg.show(getFragmentManager(),"Título"; |
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
package org.androiddes.roboxito.ejemplos; | |
import android.app.AlertDialog; | |
import android.app.Dialog; | |
import android.app.DialogFragment; | |
import android.content.DialogInterface; | |
import android.os.Bundle; | |
/** | |
* Created by @roboxito on 15/02/15. | |
*/ | |
public class MensajeDialogo extends DialogFragment { | |
private String mensaje; | |
public void setMensaje(String mensaje) { | |
this.mensaje = mensaje; | |
} | |
@Override | |
public Dialog onCreateDialog(Bundle savedInstanceState) { | |
// Use the Builder class for convenient dialog construction | |
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | |
// Set the message to display. | |
builder.setMessage(this.mensaje) | |
.setTitle(this.getTag()) | |
.setPositiveButton("OK", new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int id) { | |
//Evento al presionar botón OK | |
} | |
}); | |
// Create the AlertDialog object and return it | |
return builder.create(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment