title: setChecked() method not working in getView() of custom adapter
body: <p>This is the code of my custom adapter:</p>
  
  <pre><code>        public static class ImageAdapter extends BaseAdapter {
          private static Context mContext;
          private static LayoutInflater mInflater;
          // Keep all Images in array
          private static Bitmap[] mThumbIds;
          private static int mViewResourceId, pos;
          private static CheckBox cb;
          // Constructor
          public ImageAdapter(Context ctx, int viewResourceId, Bitmap[] pics) {
              mInflater = (LayoutInflater) ctx
                      .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              mThumbIds = pics;
              mViewResourceId = viewResourceId;
              mContext = ctx;
          }
  
          @Override
          public int getCount() {
              return mThumbIds.length;
          }
  
          @Override
          public Object getItem(int position) {
              return mThumbIds[position];
          }
  
          @Override
          public long getItemId(int position) {
              return 0;
          }
  
          @SuppressWarnings("deprecation")
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
              convertView = mInflater.inflate(mViewResourceId, null);
              // ImageButton imageView = (ImageButton)
              // convertView.findViewById(R.id.icon);
              cb = new CheckBox(mContext);
              Drawable background = new BitmapDrawable(mThumbIds[position]);
              cb.setBackgroundDrawable(background);
              pos = position;
              System.out.println("Setting checkbox set: "+imageIsDup[pos]);
              cb.setChecked(imageIsDup[pos]);
              System.out.println("Has checkbox been set? "+cb.isChecked());
              cb.setOnClickListener(new View.OnClickListener() {
                  public void onClick(View v) {
                      if (cb.isChecked()) {
                          imageIsDup[pos] = true;
                      } else
                          imageIsDup[pos] = false;
                  }
              });
              return cb;
          }
  
      }
  }
  </code></pre>
  
  <p>I'm setting the adapter like this:</p>
  
  <pre><code>GridView list = (GridView) dialog
                              .findViewById(R.id.grid_view);
                      TextView no = (TextView) dialog
                              .findViewById(R.id.noOfDups);
                      no.setText("Found " + noOfImages
                              + " duplicates. Please verify.");
                      //list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
                      dialog.setTitle("Images Found");
                      dialog.setCancelable(true);
                      // ImageAndTextAdapter adapter = new ImageAndTextAdapter
                      // (longOperationContext, R.layout.row, imageNames,
                      // imageLocs, thumb);
                      ImageAdapter adapter = new ImageAdapter(
                              longOperationContext, R.layout.row, thumb);
                      System.out.println("No of images:"+thumb.length);
                      list.setAdapter(adapter);
  </code></pre>
  
  <p>The checkboxes work fine if I click and unclick them. What doesn't work is the <code>setChecked()</code> function. Although the parameter is <code>true</code> there are no set checkboxes when it's displayed. What is the mistake?</p>
  
  <p>This code was working before, I made a few edits a while back and it hasn't worked since then. I don't remember the edits sadly.</p>
  
  <p><b>UPDATE</b>
  Even though there are only 8 images and the <code>println</code> messages should only be <code>16</code> altogether there are <code>48</code>. The first set being only false, the second two sets having the correct <code>imageIsDup</code> value.</p>