title: Custom row elements in ListFragment are displaying incorrectly after scrolling
body: <p>I have a <code>ListFragment</code> containing a list of <code>Earthquake</code> objects that populates using a custom <code>ArrayAdapter</code>. Each element is either 'highlighted' or not, depending on whether the magnitude of the earthquake is above a certain value. The problem is that after scrolling, the 'highlighted' row colors will be applied to other rows. I suspect this is to do with the caching used in the <code>ListView</code>. How can I prevent this from happening?</p>
  
  <p>Here is the <code>getView</code> method of my <code>EarthquakeArrayAdapter</code> class:</p>
  
  <pre><code>public View getView(int position, View convertView, ViewGroup parent) {
      if (convertView == null) {
          convertView = mInflater.inflate(R.layout.row, parent, false);
      }
  
      Earthquake quake = mQuakes.get(position);
      if (quake != null) {
          TextView itemView = (TextView) convertView.findViewById(R.id.magnitude);
          if (itemView != null) {
              itemView.setText(quake.getFormattedMagnitude());
              if (quake.getRoundedMagnitude() &gt;= mMinHighlight)
                  itemView.setTextColor(Color.RED);
          }
      // Set other views in the layout, no problems here...
      }
      return convertView;
  }
  </code></pre>
  
  <p>And here is my <code>row.xml</code> layout file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal" &gt;
  
      &lt;TextView
         android:id="@+id/magnitude"
         style="@style/ListFont.Magnitude" /&gt;
  
      &lt;LinearLayout
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical" &gt;
          &lt;TextView
              android:id="@+id/date"
              style="@style/ListFont.NonMagnitude"
              android:gravity="center_horizontal|top"
              android:textSize="18sp" /&gt;
          &lt;TextView
              android:id="@+id/location"
              style="@style/ListFont.NonMagnitude"
              android:gravity="center_horizontal|bottom"
              android:textSize="14sp" /&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I've watched <a href="http://www.youtube.com/watch?v=wDBM6wVEO70" rel="nofollow">this</a> video on the <code>ListView</code> widget and I'm considering doing what Adam Powell suggests at the end - dynamically populating &amp; expanding a <code>LinearLayout</code> inside a <code>ScrollView</code> and simply using that. My data is presently bounded between 0 and 30 items (I haven't yet tested this so don't know what the performance difference is likely to be). However, those bounds may not always stay the same - so I'd like to solve this, if I could.</p>