On Friday, December 16, 2011 7:27:42 AM UTC-8, plw wrote:
>
>
> ----- Original Message -----
> From: TreKing
> To: [email protected]
> 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
> <[email protected]> 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)
{
...
}
}
};
Do please read the Java coding conventions so your variable names and
indentation are compliant.
--
Lew
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en