Skip to content Skip to sidebar Skip to footer

Customize Alertdialog Footer

I want to customize the footer of the AlertDialog, I mean, the place where the buttons are located. I tried creating a separate layout and inflating it before calling builder = Ale

Solution 1:

If you wish to change the AlertDialog away from its designed format, I would recommend extending your own version of the Dialog and using it.

Solution 2:

You could also use a new Activity and set the theme to android:theme="@android:style/Theme.Dialog" in the Android Manifest. This would allow you to use your own XML layout file.

Solution 3:

In that case, why don't use custom dialog instead of alertdialog?

Solution 4:

The setNegativeButton() and setPositiveButton() methods place the buttons at pre-defined locations. This is the reason that you are able to customize everything but the placement of buttons when you inflate a layout onto an AlertDialog.

Your options are:

  1. Do not use the setNegativeButton() or such methods - instead, add your own custom buttons in your layout. This means you would need to listen for specific button clicks. Somehow, this solution does not appeal to me since an AlertDialog is not meant to be used this way
  2. Use a custom dialog as mentioned in other answers (explained here).

@Phil s suggestion above looks interesting. I haven't tried it out though.

Solution 5:

Also, while you are extending the Dialog, you may want to set it up so that it does not use the default title ( in order to have a consistent / fully customized look and feel ). This can be accomplished via:

" dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); "

Post a Comment for "Customize Alertdialog Footer"