Bruno Oliveira Bruno Oliveira - 1 month ago 24
Android Question

Android AlertDialog style

I'm creating a android AlertDialog but then show it the appearence is:

MyAlertDialog

but I want the style to be like this:

AlertDialog Android Developer

My code:

private void showAlertDialog(String message) {
Log.i("LOG", getText(R.string.class_main) + "showAlertDialog()");

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(message)
.setTitle(getText(R.string.retorno_comando))
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//something here
}
});

AlertDialog dialog = builder.create();
dialog.show();
}

Answer

Looks like you just need to specify the style you want when you initialize the builder. That style of dialog is an older style known as Holo. I think this is the style you want.

AlertDialog.Builder builder = new AlertDialog.Builder(this, android.R.style.Theme_Holo_Dialog);
Comments