title: android listview adapter checkbox refreshing
body: <p>Note:  This isn't the common problem of scrolling causing the checkboxes to lose their way.</p>
  
  <p>I have a listview adapter with a relativelayout (containing a textview and a checkbox) as the listview row, and I want to make it so when a user clicks on the listview row... then the checkbox will toggle.</p>
  
  <p>I've got it working right now almost, but what's happening is the checkbox doesn't show me that it has toggled until I scroll the row off the screen and then come back.  So it seems like it's not refreshing properly.  My guess is I need to explicitly do something else with the checkbox listener.  Here's my code:</p>
  
  <pre><code>         ViewHolder holder = null;
          MainContactsListOnOff entry = listMaincontactslistOnOff.get(position);
          if (convertView == null) {
              LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
              convertView = inflater.inflate(R.layout.contact_rowonoff, null);
  
          holder = new ViewHolder();
          holder.code = (TextView) convertView.findViewById(R.id.textView1onoff);
          holder.name = (CheckBox) convertView.findViewById(R.id.checkBox1onoff);
          holder.img = (ImageView) convertView.findViewById(R.id.imageView1onoff);
          convertView.setTag(holder);       
  
          } else {
              holder = (ViewHolder) convertView.getTag();
          }
       holder.code.setText(entry.getName().toString());
    if(entry.getOnoff()==1){
        holder.img.setImageResource(R.drawable.green);
    } else {
        holder.img.setImageResource(R.drawable.red);
    }
       convertView.setId(entry.getDevID());
       holder.name.setTag(entry);
       holder.name.setChecked(entry.getChecked());
  
       convertView.setOnClickListener(new OnClickListener(){
  
              @Override
              public void onClick(View arg0) {
                  // TODO Auto-generated method stub
                  RelativeLayout rl = (RelativeLayout) arg0;
                  CheckBox chkBx = (CheckBox) rl.getChildAt(1);
                  MainContactsListOnOff mclOO = (MainContactsListOnOff)   chkBx.getTag();
                  if(chkBx.isChecked()){
                      mclOO.setChecked(false);
                  } else {
                      mclOO.setChecked(true);
                  }
  
              }
  
          });
        return convertView;
  </code></pre>