Hi,

Are you sure that the following line is correct?

    for(int i = 0; i <=counter; i++)

I think it must be: for(int i = 0; i < counter; i++)

On Sun, Nov 13, 2011 at 12:30 PM, benjamin <tan.benjamin.fil...@gmail.com>wrote:

> hi to all, i am currently having problems with my dynamic checkboxes,
> if i uncomment my isChecked(), my program will be forced closed.
> however, if i comment it, my program will run. however this will
> defeat what i want to happen. My goal is if the checkbox is chacked
> and I pressed the button, automatically it will be removed from the
> linear layout. here is my code
>
>
>  case R.id.mainCoButtonOrderNow:
>                        LinearLayout ll= (LinearLayout)
> findViewById(R.id.coLinearLayout1);
>                        cbs[counter] = new CheckBox(this);
>                        cbs[counter].setText("I'm dynamic!");
>                        cbs[counter].setId(counter);
>                        cbs[counter].setOnClickListener(this);
>                        ll.addView(cbs[counter]);
>                        counter++;
>                        break;
>                case R.id.mainCORemoveButton:
>
>                         for(int i = 0; i <=counter; i++) {
>
>                                        //if(cbs[i].isChecked()){
>          <--------- here is
> the problem :(
>                                                LinearLayout ll2=
> (LinearLayout)
> findViewById(R.id.coLinearLayout1);
>                                                ll2.removeView(cbs[i]);
>                                        //}
>                                        //else{}
>
>
>                                 }
>
>                     break;
>
> --
> 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




-- 
Adriano Godinho

-- 
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