title: Is there any way to restrict the selection of the check box in list view according to the dynamic value?
body: <p>I am having a list view (say 10 items with check boxes), I want to restrict the user to select <code>i</code> items (i.e.,i=1 or 2 or 3 or 4...).</p>
  
  <p>Say if <code>i=3</code>, 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.</p>
  
  <p>How can I restrict the user to select particular items from the list view?</p>
  
  <p>Here is my listener:</p>
  
  <pre><code>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&gt;i) {
                  buttonView.setChecked(false);
                  model.setChecked(false);
              }
          }
  
      });
  </code></pre>