Customize Alertdialog Footer
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:
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:
- 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 - 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"