friends,
i want to limit checkbox selection in android listivew to for example only 3 checkboxes should be selected otherwise it should give error message.
u
finally i solved this issue :) where as globalInc is global variable with default value 0
holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton checkboxView, boolean isChecked)
{
myContacts c = (myContacts) checkboxView.getTag();
if(isChecked)
{
globalInc++;
}
else if(!isChecked)
{
globalInc--;
}
if(globalInc >= 4)// it will allow 3 checkboxes only
{
Toast.makeText(context, "Error = " + globalInc, Toast.LENGTH_LONG).show();
checkboxView.setChecked(false);
globalInc--;
}
else
{
c.setSelected(isChecked);
}
System.out.println(" --------------- "+globalInc);
}
});