title: select all checkboxes of Listview in android
body: <p>I'am having <strong>Custom dialog</strong> in which i've displayed a <strong>listView</strong> with <strong>checkboxes</strong>.I want to select all checkBoxes of ListView by Clicking button in dialog.</p>
  
  <p>here is my button onClickListener</p>
  
  <pre><code>selectAll.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View view) {
                  for (int i = 0; i &lt; listView.getChildCount(); i++) {
            LinearLayout myLayout =(LinearLayout)listView.getChildAt(i);
            CheckBox cb = (CheckBox) myLayout.findViewById(R.id.checkbox);
            cb.setChecked(true);
                 }
              }
          });
  </code></pre>
  
  <p>with above code i have can only check those checkboxes which are on view.
  I know this happens because listView reuses views.
  please suggest me what to do</p>