1
I put it in my app where you can show the dialog to exit the application, but the dialog is black. I wanted it to be white. How do I change the theme of AlertDialog
?
@Override // SAIR DA APLICAÇÃO
public void finish() {
if (sair) {
AlertDialog.Builder alerta = new AlertDialog.Builder(this);
alerta.setTitle("Sair");
alerta.setIcon(R.mipmap.ic_launcher);
alerta.setMessage("Tem certeza de que deseja sair do xxxxx")
.setCancelable(false)
.setPositiveButton("SIM",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
sair = false;
finish();
}
})
.setNegativeButton("NÃO",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
dialog.cancel();
}
});
AlertDialog alertDialog = alerta.create();
alertDialog.show();
} else {
super.finish();
}
}
On which Android are you testing? Also, show a screenshot with this dialog.
– Pablo Almeida
Plabo already managed, just insert a line of code in what needed to show the white Alertdialog, say the background theme. Thanks, @Override // QUIT APPLICATION public void Finish() { if (quit) { modified chunk Alertdialog.Builder alerta = new Alertdialog.Builder(this, android.R.style.Theme_material_light_dialog_alert);
– Anselmo Cardoso
@Anselmocardoso if you want you can answer your own question.
– Jorge B.