I am working on quiz application. For each question there are multiple options should be selected. For that I have used checkboxes. When check box is checked I am storing the checked id value in arraylist and if unchecked I am removing that id from the arraylist. Also before this I am adding the number of answers for each question in the arraylist and in the next button click I am adding an “|”(or) symbol to differentiate the questions.
So for example 3 questions are displayed….then my arraylist contains

Now for the first question I selected 3 option, for second question I selected 4 options and for third question I didnt select any of the option. So for third question only the number of correct answers and the | symbol is displayed. But now my problem if none of the checkboxes are selected I want to pass a value in the arraylist. How can I do that? Please help me regarding this….Struggling for this since 3 days….
My Code:
cbs[k].setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (((CheckBox) v).isChecked()) {
selchkboxlist.add(Integer.toString(v
.getId()));
System.out.println("chkboxlist size"
+ selchkboxlist.size());
}
else
{
selchkboxlist.remove(Integer.toString(v
.getId()));
System.out
.println("after delete chkboxlist size"
+ selchkboxlist.size());
}
}
});
Will be thankful in advance
Then before going to next question check your arraylist..