I create AlertDialog with ListView, and adapter have element CheckAll/UncheckAll elements programmatically. This works. But when I'm checking item by touching screen, then push checkall, then uncheckall the checked element stays checked.
DialogInterface.OnMultiChoiceClickListener coloursDialogListener = new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which,
boolean isChecked) {
ListView list = ((AlertDialog) dialog).getListView();
long[] a = list.getCheckItemIds();
if (which == 0) {
if (isChecked) {
for (int i = 0; i < list.getCount(); ++i)
list.setItemChecked(i, true);
} else {
for(int i=0;i<list.getCount();++i)
list.setItemChecked(i, false);
}
a = list.getCheckItemIds();//fucntion return empty array
//but on screen checked element is Check.
return;
}
}
};
Update: I'm find when the bug occurs. if in function
setMultiChoiceItems(CharSequence[] items, boolean[] checkedItems, DialogInterface.OnMultiChoiceClickListener listener)
I set parameter checkedItems the bug occurs. And if I set checkedItems parameter null bug not occurs. Have any idea?
UPDATE: I open the issue on bugtracker google, for more datails look here