last day (15 days later) » 

8:19 PM
0
A: Check all checkboxes when top box gets checked

Larry McKenzieSo I modified your listener but I have not tested this myself. Also I don't think you need an onClickListener for your CheckBoxes. @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Integer index = (Integer) buttonView.getTag(); if(index == 0 && checke...

 
Hmm.. Now the topmost checkbox stays checked all the time and I can't uncheck it?
 
I edited my answer a bit.
 
Still doesn't work? Sorry saw you edited again will give it a go! ** The topmost box does work again but when I tap it it doesn't check all checkboxes
 
The trick is preventing an infinite loop because every-time the data set is invalidated it will call onCheckChanged again. I made some more changes as I'm thinking though it, give it another go.
 
Same as a few mins ago. The topmost checkbox is working as are the other ones, but the first one doesn't check them all
 
8:19 PM
Sorry about all of the edits, we are getting close though.
 
No problem, I will give each edit a go and report back to you
Hi
 
hello
 
After this edit it is like before, the topmost box is checked but cannot be unchecked
 
ok i will keep looking at it
 
ok :)
Any change yet?
 
8:34 PM
sorry was mid email I am looking at it again.
 
did you remove the onclick listener in your getView method?
 
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// on each click change the state of checkbox
box.setChecked(!box.isChecked());
}
});
that?
 
ya it isn't required when using checkboxes and I am curious if it is calling the check twice
 
It is used to make the text before the boxes clickable. So that when I click on the text the box next to it gets checked
 
8:43 PM
another question, do you want to uncheck all boxes when the user unchecks all
 
but i deleted it and the same thing, the topmost checkbox stays checked
So its not calling the check twice hehe
 
ok good deal
 
and you mean that if i tap the topmost box that everything gets unchecked including that topmost box?
 
ya I am curious if that is the desired functionality
 
well heres a screenie
"All" I cant uncheck that one
but what needs to happen is:
When I click on "All" Every other category below has to be checked
and when I click "All" again every other category below has to be unchecked
 
8:48 PM
ok
so here is the issue:
when you create the views in getView onCheckedChange is called for each item
this means that if "all" should check all when checked and un-check all when unchecked then none of the other checks will ever work.
 
we need to know when a user checks the box vs when the programs calls it
 
Well.. you're the master!
I'm still a newbie to all this programming :P
 
I think if we remove the oncheckedchange listener in getview before setting the checked state and then re add it we may have a solution
I am no master :)
 
If you could put that solution in code
 
8:59 PM
I am working on it at the moment be done soon
 
okay I updated my answer, let me know how it goes...
 
I just replace my whole MyAdapter?
 
sure I made a few changes throughout but it is mostly the same
 
Gonna run it now
Hmm.. Working exactly like before, but i can uncheck "all"
But when I check it it doesn't check the rest of the boxes
 
9:15 PM
ok then I am missing something clearly, do all of the other boxes work?
 
Yes the rest is working
 
have any of my iterations checked the other boxes?
 
How do you mean/
?
 
if you check "all" and exit the app then reenter is everything checked?
 
Just a sec
 
9:18 PM
I am curious if notifyDataSetChanged(); is not refreshing the views
 
When I reenter it is the same as when I leaved the app
because the checkbox states get saved in sharedpref
 
ok one sec
 
trying something different that I don't expect to work exactly right but help me understand something. see my edit
 
Ok just a sec will report back to you in a sec
 
9:34 PM
try the same test I had you try earlier by leaving the app using the back button and returning
 
Ok
here's what happens
I open the app
go to the listview
tap "all"
press back button
go back to listview
Everything is checked
Then when everything is checked and I tap "all"
press back button
go back to listview
everything is unchecked
 
ok thanks for the detailed description
 
I think this is almost what i want :)
 
now we just need the view to update appropriatly
 
Exactly
 
9:38 PM
appropriately*
 
so that i don't have to go back and fourth to see the changes
 
ok so I have re-added the notifyDataSetChanged() part, this is supposed to tell the adapter to re-draw the visible views.
my concern is that it is also calling the checkedchangelistener
 
I will give it a go, I will save the current My Adapter for backup
My friend
it is working
FINALLY
When I tap "all" all the checkboxes get checked
same for unchecked state :)
 
ok good deal I made one final adjustment as I placed notifyDataSetChanged(); in the wrong spot.
 
9:46 PM
i accidentally put it in the loop which is not efficient
 
if I have anymore problems or things to ask I will consult you via this chat
:0
:)*
 
sorry that took so long
have a good day
 
No problem, we both learned. One more small thing, in the listview when i scroll end i reach the end a blue color gets displayed at the end of the list
how can I hide that?
setOverscrollmode or something?
 
10:15 PM
got it, was: listView.setOverScrollMode(View.OVER_SCROLL_NEVER);
 

last day (15 days later) »