Basically, you want to access the dialog buttons: they (on the standard AlertDialog) currently have identifiers android.R.id.button1for positive, android.R.id.button2negative and android.R.id.button3neutral.
So, for example, to set the background image to a neutral button, you can do this:
Dialog d;
((Button)d.findViewById(android.R.id.button3)).setBackgroundResource(R.drawable.new_background);
EDIT: this is if you use AlertDialog.Builder to create it. As far as I know, these buttons may change in the future, so keep that in mind.
EDIT: The code snippet below should generate what looks like what you want. Turns out you need to call the show before you change the background
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("TEST MESSAGE)
.setPositiveButton("YES", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
})
.setNegativeButton("NO", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
((Button)alert.findViewById(android.R.id.button1)).setBackgroundResource(R.drawable.button_border);
source
share