i am new in android.i make a simple maths apps.
i use the check box for select right option but problem is here the answer option is not only one but also two,three means multi select so i use the check box
chkOption.setOnCheckedChangeListener(this);
event and try to handle this.and store the select value in one Arraylist.but when i select option the value is add in arrayList but when i do uncheck(Diselect) then also the event is occur and the value add in arraylist.
my code is below
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
CheckBox chk=(CheckBox) buttonView;
if(chk.isChecked())
{
forMetchCheckBox.add(String.valueOf(chk.getText()));
}
}
forMetchCheckbow is my String ArrayList .So i can what to do?
How to Handle this problem.
if any user deselect the option then the checkbox select value is remove from ArrayList.it`s possible?
It seems you are having more than one checkbox and you are setting global listener for every checkbox. So, in that case you need to identify the event for specific checkbox also.
and so on, that will make your listener work perfect.