title: How to check all checkbox in gridview using another checkbox or a button
body: <p>I know this question is familiar but i need help. I don't know why my code returns a null pointer. here I got so far:</p>
  
  <pre><code>    final GridView imagegrid = (GridView) findViewById(R.id.grid_GalleryImage);
      imageAdapter = new ImageAdapter();
      imagegrid.setAdapter(imageAdapter);
  
      // Check All
  
      Button btnCheckAll = (Button) findViewById(R.id.btn_SelectAll);
      btnCheckAll.setOnClickListener(new OnClickListener() {
              public void onClick(View v) {
                  int count = imagegrid.getAdapter().getCount();
                  for (int i = 0; i &lt; count; i++) {
                      LinearLayout itemLayout = (LinearLayout)imagegrid.getChildAt(i); // Find by under LinearLayout
                      CheckBox checkbox = (CheckBox)itemLayout.findViewById(R.id.cbo_CheckImage);
                      checkbox.setChecked(true);
                  } 
              }
      });
  </code></pre>