title: Custom ArrayAdapter setBackground in getView
body: <p>I'm working on a ListActivity which will display a bunch of numbers (weights). I would like to change the background of a specific row in the ListView. To do this I have created a custom implementation of the ArrayAdapter class and have overridden the getView method. The adapter accepts a list of numbers and sets the background of the row with the number 20 to yellow (for simplicity reasons).</p>
  
  <pre><code>    public class WeightListAdapter extends ArrayAdapter&lt;Integer&gt; {
  
      private List&lt;Integer&gt; mWeights;
  
      public WeightListAdapter(Context context, List&lt;Integer&gt; objects) {
          super(context, android.R.layout.simple_list_item_1, objects);
  
          mWeights = objects;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          View v = super.getView(position, convertView, parent);
  
          int itemWeight = mWeights.get(position);
          if (itemWeight == 20) {
              v.setBackgroundColor(Color.YELLOW);
          }
          return v;
      }
  
  }
  </code></pre>
  
  <p>The problem is that not only the row with the number 20 gets the yellow background but also the row with the number 0 (the first row that is) and I'm not sure why this is so.</p>
  
  <p>Am I doing something wrong in the getView method (like calling the super method)? My reasoning for the implementation is: All the returned views should be the same (that's why I'm calling the super method) only the view fitting the if criteria should be changed.</p>
  
  <p>Thanks for your help!</p>