I am having a list view (say 10 items with check boxes),I want to restrict the user to select i items(i.e.,i=1 or 2 or 3 or 4...).say if i=3,the user can only select 3 check boxes from the list,he will be not able to select the 4th check box.And if we scroll the list view the items will get reset to the old values as we know that can be handle by using Boolean state in the model class.
How can i restrict the user to select particular items from the list view?
here is my listener:
final int i=3;
holder.cb_check.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
model.setChecked(isChecked);
if (isChecked) {
GlobalCounter++;
} else {
GlobalCounter--;
}
if (GlobalCounter>i) {
buttonView.setChecked(false);
model.setChecked(false);
}
}
});
Need help.. Thank in advance..!!
Aucun commentaire:
Enregistrer un commentaire