Generalidades
Cómo mostrar un mensaje de alerta en Android (JAVA) – Rıza Doğukan Koşar


- Cree un generador de diálogo:
AlertDialog.Builder alert = new AlertDialog.Builder(this);2. Título y mensaje:
alert.setTitle("My Title");
alert.setMessage("The message in Alert");3. Botones:
alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "Pushed yes", Toast.LENGTH_SHORT).show();
}
});alert.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "Pushed no", Toast.LENGTH_SHORT).show();
}
});
4. Se muestra el cuadro de diálogo:
alert.show();Código completo:
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("My Title");
alert.setMessage("The message in Alert");
alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "Pushed yes", Toast.LENGTH_SHORT).show();
}
});
alert.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "Pushed no", Toast.LENGTH_SHORT).show();
}
});
alert.show();
![Arquitectura nativa de React - [part one] | Por Salama Salem | febrero de 2022 7 Arquitectura nativa de React - [part one] | Por Salama Salem | febrero de 2022](https://sistemaandroid.info/wp-content/uploads/2022/02/Arquitectura-nativa-de-React-part-one-Por-Salama-220x150.png)






