Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Using a for loop for a list of check boxes

I was seeing if I could use a for loop so that when a check box is selected all the other check boxes become deselected. It's using an arraylist api so that the array holding the check boxes shrinks or grows depending on the amount of values inside the array.

1 Answer

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Are the checkboxes inside items of a ListView? If so, we're about to cover this in the upcoming Android course. The ListView class has a few methods that make it easy to deal with checked items. If you only want to let users select one item at a time,

getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); API link