Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a listview in main activity with a custom adapter class which has a text view and a checkbox in it. I can get the checked items from the code but when I set uncheck all the checkboxes from the code, it wouldn't change on the Android device LCD. Their states are unchecked from the code but still checked on the LCD!

What I have tried:

Below code is what I have tried for unchecking the checkboxes, their states are changed but nothing is changed on the LCD.
Java
for (int i = 0; i < ((CustomAdapter) LstExt.getAdapter()).getCount(); i++) {
                    View v = ((CustomAdapter)LstExt.getAdapter()).getView(i, null, LstExt);

                    ItemHolder b = (ItemHolder) v.getTag();
                    b.chkSelect.setChecked(false);
                    CheckBox cb = v.findViewById(R.id.Chk);
                    cb.setChecked(false);

                }
Posted
Updated 31-Dec-18 22:11pm
v3
Comments
Richard MacCutchan 1-Jan-19 4:00am    
You probably need to force the View to refresh itself.
marimir 1-Jan-19 4:01am    
How can I do it?
Richard MacCutchan 1-Jan-19 4:11am    
See below.

1 solution

 
Share this answer
 
Comments
marimir 1-Jan-19 4:31am    
I use refreshDrawableState for the listview and every checkbox but it is still the same!
Richard MacCutchan 1-Jan-19 4:36am    
Follow the link above and do what the documentation suggests.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900