----- Original Message ----- From: Lew
To: android-developers@googlegroups.com
Sent: Friday, December 16, 2011 4:21 PM
Subject: Re: [android-developers] How do you loop through check boxes




On Friday, December 16, 2011 7:27:42 AM UTC-8, plw wrote:

----- Original Message ----- From: TreKing
To: android-d...@googlegroups.com
Sent: Friday, December 16, 2011 3:16 PM
Subject: Re: [android-developers] How do you loop through check boxes

On Fri, Dec 16, 2011 at 9:08 AM, Knutsford Software
<in...@knutsford-software.co.uk> wrote:
How do you loop through all the check boxes in thee onclick to the submit
button so that I can see which ones are set and ehich ones aren't
Save them in a list .....
Sorry I don't follow you. How do I do that in the onclick?. I need to loop
throught them and make a list but how do I loop through them?
He meant save them when you create them. Obviously it's too late to save them when you're in the 'onClick()'.


So, during the create loop:


public class YourScreen
{
 private final List<CheckBox> allCheckBoxes = new ArrayList<CheckBox>();
...


 private void createUI()
 {
   CheckBox cb = ...;
   allCheckBoxes.add(cb);
  ...
 }


 OnClickListener clickHandler = new OnClickListener()
 {
   @Override
   public void onClick(View v)
   {
     for (CheckBox cb : allCheckBoxes)
     {

       ...

     }

   }
 };






Thanks I suddenly realised that was what he meant but I still wasn't sure about looping through afterwards. It is a straight for then not a foreach?




Pam


--
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to