tags:

views:

34

answers:

1

I want to display a multichoice list in an alert dialog box. If I'm using an array to store the list of items, then it is working fine :

d.setMultiChoiceItems(R.array.items,
                    new boolean[]{false, true, false, true, false, false, false},
                    new DialogInterface.OnMultiChoiceClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton,
                                boolean isChecked) {

                            /* User clicked on a check box do some stuff */
                        }
                    })

But in my case, the item list is dynamic, which I'm geting from a database. The database keeps on updating its contents and hence the list is also updating at a fixed interval of time. So, instead of using an array I would like to use a cursor in the argument of setMultiChoiceItems. Can anyone please tell me how to do it....?

A: 

Just use another version of setMultiChoiceItems(), the one that takes a Cursor as a parameter. You also give it the name of the columns in the result set that represent the label and the boolean checkbox setting.

CommonsWare