4

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.?

suresh cheemalamudi
  • 6,190
  • 11
  • 49
  • 67
  • 3
    My suggestion is to create a fully customable dialog, for example in your dialog only the content is custom, but you can create a full custom dialog, [here is the offical ducumentation](http://developer.android.com/guide/topics/ui/dialogs.html#CustomLayout). So you have to create the dialog with custom title and custom content. I hope it helps! – kameny Dec 01 '12 at 09:33

1 Answers1

3

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()

android.fryo
  • 1,469
  • 1
  • 14
  • 18