title: Change ListView background - strange behaviour
body: <p>I have a problem with changing the background of a view in a ListView.</p>
  
  <p><strong>What I need:</strong><br>
  Change the background image of a row onClick()</p>
  
  <p><strong>What actually happens:</strong><br>
  The background gets changed (selected) after pressing e.g. the first entry. But after scrolling down the 8th entry is selected too.
  Scroll back to the top the first isn't selected anymore. The second entry is selected now.
  Continue scrolling and it continues jumping...</p>
  
  <p><strong>What i'm dong in the Code:</strong><br>
  I have channels, and onClick() I toggle an attribute of channel <strong>boolean selected</strong>
  and then I change the background.
  I'm doing this <strong>only</strong> onClick() thats why I don't get why it's actuelly happening on other entries too.
  One thing I notices is: It seems to be only the "drawing"-part because the item which get selected "by it self" has still the <strong>selected</strong> value on <strong>false</strong>  </p>
  
  <p>I think it seems to have something to do with the reuse of the views in the custom ListAdapters getView(...)</p>
  
  <p><strong>Code of onClick() in ListActivity:</strong></p>
  
  <pre><code>@Override
      protected ViewHolder createHolder(View v) {
  
          // createHolder will be called only as long, as the ListView is not
          // filled
  
          TextView title = (TextView) v
                  .findViewById(R.id.tv_title_channel_list_adapter);
          TextView content = (TextView) v
                  .findViewById(R.id.tv_content_channel_list_adapter);
  
          ImageView icon = (ImageView) v
                  .findViewById(R.id.icon_channel_list_adapter);
  
          if (title == null || content == null || icon == null) {
              Log.e("ERROR on findViewById",
                      "Couldn't find Title, Content or Icon");
          }
          ViewHolder mvh = new MyViewHolder(title, content, icon);
  
          // We make the views become clickable
          // so, it is not necessary to use the android:clickable attribute in
          // XML
  
          v.setOnClickListener(new ChannelListAdapter.OnClickListener(mvh) {
  
              public void onClick(View v, ViewHolder viewHolder) {
                  // we toggle the enabled state and also switch the the
                  // background
                  MyViewHolder mvh = (MyViewHolder) viewHolder;
                  Channel ch = (Channel) mvh.data;
                  ch.setSelected(!ch.getSelected()); // toggle
  
                  if (ch.getSelected()) {
                      v.setBackgroundResource(R.drawable.row_blue_selected);
                  } else {
                      v.setBackgroundResource(R.drawable.row_blue);
                  }
                  // TESTING
                  Log.d("onClick() Channel", "onClick() Channel: "
                          + ch.getTitle() + " selected: " + ch.getSelected());
              }
          });
  return mvh;
      }
  </code></pre>
  
  <p><strong>Code of getView(...):</strong></p>
  
  <pre><code>@Override
  public View getView(int position, View view, ViewGroup parent) {
      ViewHolder holder;
  
      // When view is not null, we can reuse it directly, there is no need
      // to reinflate it.
      // We only inflate a new View when the view supplied by ListView is
      // null.
      if (view == null) {
          view = mInflater.inflate(mViewId, null);
  
          // call own implementation
          holder = createHolder(view);
  
          // TEST
          // we set the holder as tag
          view.setTag(holder);
  
      } else {
          // get holder back...much faster than inflate
          holder = (ViewHolder) view.getTag();
      }
  
      // we must update the object's reference
      holder.data = getItem(position);
  
              // &lt;EDIT SOLUTION&gt;
  
      if(getItem(position).get_id() == channelList.get(position).get_id()){
          if(getItem(position).getSelected())
          {
              view.setBackgroundResource(R.drawable.row_blue_selected);
          }
          else{
              view.setBackgroundResource(R.drawable.row_blue);
          }
      }
  
              // &lt;/EDIT SOLUTION&gt;
  
      // call the own implementation
      bindHolder(holder);
  
      return view;
  }
  </code></pre>
  
  <p>I really would appreciate any idea how to solve this! :)</p>
  
  <p>If more information is needed please tell me.</p>
  
  <p><strong>Thanks in advance!</strong></p>