title: ListView multiple select with custom layout
body: <p>I am trying to make a gmail-like listview. That is, initially, the listview is in single choice mode, but when a checkbok is selected, it becomes multiple choice. </p>
  
  <p>this is what i have so far:</p>
  
  <pre><code>     SimpleCursorAdapter dataSource = new SimpleCursorAdapter(this, R.layout.listitem, cursor,
               new String[]{"_id","a","b","c","d","e","f","g","h"}, 
               new int[] { R.id.checkBox1, R.id.a, R.id.b, R.id.c, R.id.d, R.id.e}
  // all of these are a part of my list item custom layout.
               );
  
      dataSource.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
  
  @Override
  public boolean setViewValue(View aView, final Cursor c, int i) {
  
      String s=c.getString(i);
      String toset="";
      TextView tv = i==0?null: (TextView) aView;
      if (i==0){
          if(chkL==null){
              chkL=new OnCheckedChangeListener() {
                  @Override
                  public void onCheckedChanged(CompoundButton cb1, boolean isChecked) {
                      CheckBox cb=(CheckBox) cb1;
                      chkid[c.getPosition()]=isChecked;
  
                      if(lv.getChoiceMode()!=lv.CHOICE_MODE_MULTIPLE){
                          lv.setChoiceMode(lv.CHOICE_MODE_MULTIPLE);
                      }
                      lv.setItemChecked(c.getPosition()+1,isChecked);
                      log(isChecked+" selected "+(c.getPosition()+1));
                  }
  
          };
          }
  
          CheckBox cb= (CheckBox) aView;
          cb.setOnCheckedChangeListener(chkL);
  
          return (i==0);
      }};
  </code></pre>
  
  <p>Currently I am trying to at least make the item "selected" by pressing the checkbox against it. I am using <code>c.getPosition()+1</code> (cursor's position) to get the position of the list item tapped. but that always seems to return <code>1</code> or sometimes, random values. </p>
  
  <p><strong>update:</strong>
  Looks like it always returns 1, but when i iterate through getCheckedItemPositions(), i see that item no. 10 gets selected. Tap another checkbox, again the cursor position will be 1 but item no 11 will get selected and so on. But if i tap outside the checkbox, the correct item is selected.</p>
  
  <p>Also, on selecting one checkbox, if you scroll down, you would see that several other checkboxes are checked. (I have about 255 items in the list). I think its due to android's way of reusing the same checkboxes ?</p>