I actually have another question about an understanding of a particular 
behavior. I found that whenever I clicked on a CheckBox, while other items 
are being added to the list, it seems to move to other items in the list. 
Sometimes it would even check off another item's CheckBox at the same time 
as I check off something else.

I found a few posts relating to this and it was suggested that I set the 
checked status during the getView method, the same time I bind the other 
data to it. That makes sense, however when I go to do that I get the same 
behavior. I then tried resetting the listener, by setting it to null, based 
off someone else's code, before I set the checked status and set the 
listener again. And now it works! What I want to know is why? I don't 
understand how resetting the listener affects the check status.

   public View getView(int position, View convertView, ViewGroup parent)
   {
      CheckBoxItemView   itemView;

      // Create a new view if this one is null
      if (convertView == null)
      {
         itemView = new CheckBoxItemView(app_context);
      }
      else
      {
         itemView = (CheckBoxItemView) convertView;
      }

      // Bind the data to the new widget from the data from given list
      itemView.setName(device_list.get(position).getName());
      itemView.setText(device_list.get(position).getText());
      itemView.setIconImage(device_list.get(position).getIconImage());

      // Reset the listener for the CheckBox its checked status
      itemView.getCheckBox().setOnCheckedChangeListener(null);
      itemView.setChecked(device_list.get(position).isChecked());

      // Set the listener for the CheckBox
      itemView.getCheckBox().setOnCheckedChangeListener(
         device_list.get(position));

      return itemView;
   }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to