Is it possible to add drawables to the positive, negative and neutral buttons of an AlertDialog? If yes, then how?
+1
A:
After you have built the AlertDialog in onCreateDialog you can use the following code in onPrepareDialog to add an image to the positive button:
@Override
protected void onPrepareDialog(int id, Dialog dialog) {
super.onPrepareDialog(id, dialog);
AlertDialog alertDialog = (AlertDialog)dialog;
Button button = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
button.setCompoundDrawablesWithIntrinsicBounds(this.getResources().getDrawable(
R.drawable.icon), null, null, null);
}
Trying to add the drawable to the button in the onCreateDialog method does not seem to work.
Frank
2010-09-09 19:12:12
Will try and get back to this Frank.
Ragunath Jawahar
2010-09-17 07:15:29