title: Change the visibility of all checkbox in gridview adapter class
body: <p>I want to make all the invisible checkbox visible by longclick of image. But this makes only one checkbox visible.</p>
  
  <pre><code>   public GridViewAdapter(Context context, int layoutResourceId, 
    ArrayList&lt;ImageItem&gt; data) {
  
  super(context, layoutResourceId, data);
  
  this.layoutResourceId = layoutResourceId;//id of grid_item_layout
  this.context = context;
  this.imageFiles = imageFiles;
  this.data = data;
  }
   public View getView(final int position, final View convertView, @NonNull 
  ViewGroup parent) {
  row = convertView;
  final ViewHolder holder;
  
  if (row == null) {
  
      LayoutInflater inflater = ((Activity) context).getLayoutInflater();
      row = inflater.inflate(layoutResourceId, parent, false);
      holder = new ViewHolder();
      //find resource...
      holder.image = (ImageView) row.findViewById(R.id.image);
      holder.imageTitle = (TextView) row.findViewById(R.id.text);
      holder.check = (CheckBox) row.findViewById(R.id.checkbox);
   row.setTag(holder);
   }
   else
  {  holder = (ViewHolder) row.getTag();}
  holder.check.setOnCheckedChangeListener(null);
  holder.check.setFocusable(false);
  
   holder.image.setOnLongClickListener(new View.OnLongClickListener() {
  @Override
  public boolean onLongClick(View view) {
      holder.check.setVisibility(View.VISIBLE);
      return  true;
  }
  });
    holder.check.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
  
          if (data.get(position).isSelected()) {
              data.get(position).setSelected(false);
          } else {
              data.get(position).setSelected(true);
          }      
  
      }
  });
  
  
    holder.check.setChecked(data.get(position).isSelected());
   holder.imageTitle.setText(data.get(position).getTitle());
  
  holder.image.setImageBitmap(data.get(position).getImage());
  return row;
  }
  static class ViewHolder {
  TextView imageTitle;
  ImageView image;
  CheckBox check;
  }
  </code></pre>
  
  <p>my ImageItem class</p>
  
  <pre><code>public class ImageItem {
      private Bitmap image;
      private boolean selected;
      private String title;
  
      public ImageItem(Bitmap image, String title) {
          super();
          this.image = image;
          this.title = title;
      }
  
      public Bitmap getImage() {
          return image;
      }
  
      public void setImage(Bitmap image) {
          this.image = image;
      }
  
      public String getTitle() {
          return title;
      }
  
      public void setTitle(String title) {
          this.title = title;
      }
  
  
      public void setSelected(boolean selected) {
          this.selected = selected;
      }
      public boolean isSelected() {
          return selected;
      }
  
  }
  </code></pre>
  
  <p>This is used to maintain the state of checkbox.
  I previously changed the visibility in mainactivity as follows</p>
  
  <pre><code>GridAdapter = new GridViewAdapter(this, R.layout.grid_item_layout, 
  
  getData());
  gridView.setAdapter(gridAdapter);
  // gridView.OnLongclick....
  for(int index=0;index&lt; adapterView.getChildCount();index++) {
       View nextchild = (adapterView.getChildAt(index));
       CheckBox checkBox = (CheckBox) nextchild.findViewById(R.id.checkbox);
       checkBox.setVisibility(View.VISIBLE);
  }
  </code></pre>
  
  <p>But i faced some others problems in this method, so want to change the state of checkbox in adapter class itself. Iam struck on this for two weeks. Any help is appreciated. </p>