Tuesday, April 12, 2011

[android-developers] Programatically unchecking items in a dialog

Hello,

I am displaying a list with checkboxes in a dialog. The list looks
something like-
Item 1

Item 2

All

with a checkbox beside each item. Now the requirements is- If Item 1
or Item 2 or both are already checked, and All is selected, Item 1 & 2
should be unchecked.

To accomplish this, I implemented
DialogInterface.OnMultiChoiceClickListener 's onClick listener.
public void onClick(DialogInterface dialog, int which, boolean
isChecked)
{
if(which == 2 && isChecked)
{
((AlertDialog)dialog).getListView().setItemChecked(0, false);
((AlertDialog)dialog).getListView().setItemChecked(1, false);
}
}

But this does not work. I even tried invalidating the listview by
calling Invalidate() & InvalidateViews(), calling notifyDataSetChange
on the adapter, , but no success. Is it incorrect to update the Dialog
UI in the onClick method?

Any help will be really appreciated.

Thanks,

Akshay

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate