Search code examples
androidandroid-alertdialogcustomdialog

Custom alert dialog


I want to build a custom alert dialog with a checkbox at the title field of the AlertDialog as shown below.

enter image description here

What i have already have is this(check box is not visible, sorry for that):

enter image description here

How to get the check box here at the title field.? Also on selecting "All" options, all the other options should be selected.?


Solution

  • As kameny suggested you can go with custom dialog. You have to design a layout for that dialog as below

    Textview Checkbox
    Listview

    You can remove the dialog title using dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    Add listener to the checkbox and check whether the checkbox is selected or not. If it is selected please put a loop for items in the listview and change the checkbox status of each item in the listview. After that refresh the listview using notifydatasetchanged()