title: How to make Gridview checkbox in android behave like a RadioButton inorder to allow only single selection at a time
body: <p>I have a Android custom image gallery with checkbox in grid to select the images from the sdcard. Now I need the checkbox to act like a radio button while selecting the images so that only one image can be checked at a time.</p>
  
  <pre><code>holder.checkbox.setOnClickListener(new OnClickListener() {
      public void onClick(View v) {
          CheckBox cb = (CheckBox) v;
          int id = cb.getId();
          if (thumbnailsselection[id]) {
              cb.setChecked(false);
              thumbnailsselection[id] = false;
          } else {
              cb.setChecked(true);
              thumbnailsselection[id] = true;
          }
      }
  });
  </code></pre>
  
  <p>Here <code>thumbnailsselection[id]</code> just checks whether an image with the id passed is selected or not.</p>