Take the 2-minute tour ×

I am in the process of trying to add dynamic checkbox to my activity. However being a beginner i cant get round the basics of being able to add checkboxes and remove them. Here is my code....

private void createCheckbox() {

        cb  = new CheckBox(this);


      submit.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {

ll is a linerlayout object. The idea is when the code runs, 5 checkboxes appear and then once the user clicks on the submit button they get removed. Currently the boxes are being seen, but when the submit button is pressed only one of the five is being removed. I don't understand what i am doing wrong?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

For loop not ending correctly, curly bracket wrong place

share|improve this answer
add comment

Your Answer


