ListView showing incorrect data in views
<p>If I scroll through my ListView one TextView (expiresIn) in an listview item gets copied into others randomly. I'm guessing this has to do with the ViewHolder but I really can't see where i'm going wrong, and its only the expiresIn TextView I have the problem with:</p>

<pre><code>public class MySyncListAdapter extends CouchbaseViewListAdapter {

protected MainActivity parent;
private CouchDbConnector db;
private static final String TAG = "MySyncListAdapter";

public MySyncListAdapter(MainActivity parent, CouchDbConnector couchDbConnector, ViewQuery viewQuery) {
    super(couchDbConnector, viewQuery, true);
    this.parent = parent;
    this.db = couchDbConnector;
    Log.d(TAG, "in constructor");


}

private static class ViewHolder {
   ImageView img;
   TextView label;
   TextView dateAdded;
   TextView expiresIn;
}



@Override
public View getView(int position, View itemView, ViewGroup parent) {
    Log.d(TAG, "in getView");



    View v = itemView;
    if (v == null) {
        LayoutInflater vi = (LayoutInflater)parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(R.layout.list_item, null);
        ViewHolder vh = new ViewHolder();
        vh.label = (TextView) v.findViewById(R.id.label);
        vh.img = (ImageView) v.findViewById(R.id.img);
        vh.dateAdded = (TextView) v.findViewById(R.id.tvDateAdded);
        vh.expiresIn = (TextView) v.findViewById(R.id.tvExpiresInList);
        v.setTag(vh);
    }

    TextView label = ((ViewHolder)v.getTag()).label;
    TextView dateAdded = ((ViewHolder)v.getTag()).dateAdded;
    TextView expiresIn = ((ViewHolder)v.getTag()).expiresIn;
    ImageView img = ((ViewHolder)v.getTag()).img;
    Row row = getRow(position);
    JsonNode item = row.getValueAsNode();
    JsonNode itemText = item.get("header");
    JsonNode dateAddedText = item.get("dateAdded");
    JsonNode expiryDateText = item.get("expiryDate");
    JsonNode attachmentText = item.get("_attachments");

    ViewHolder holder = (ViewHolder) v.getTag();

    if(label != null) {
        holder.label.setText(itemText.getTextValue());
    }



    if(dateAdded != null) {
            Log.d(TAG, "in dateAdded getView");
            if(CompareDate.isDateAddedToday(dateAddedText.getTextValue())){
             holder.dateAdded.setText(R.string.today); 
            }
            else if (CompareDate.isDateAddedYesterday(dateAddedText.getTextValue())){
                holder.dateAdded.setText(R.string.yesterday);
            }
            else{
                String age = String.valueOf(CompareDate.getAgeInDays(dateAddedText.getTextValue()));
                holder.dateAdded.setText( age + " " + parent.getResources().getString(R.string.days_ago));
            }


    }


    if(!expiryDateText.isNull() &amp;&amp; expiresIn != null){
        long noDays = CompareDate.getDaysUntil(expiryDateText.getTextValue());
        if(noDays&lt;6){
            holder.expiresIn.setTextColor(Color.parseColor("#ff4444"));
        }
        holder.expiresIn.setText(String.valueOf(noDays) + " " + parent.getResources().getString(R.string.days_until_expiry));

    }



    if(img != null){
    //bitmap stuff
    holder.img.setImageBitmap(bitmap); 
    }

    return v;
}
</code></pre>

<p><strong>Update</strong>
Solved it by adding an else statement an specifically setting expiresIn to "". Would love an explaination however why if I don't specifically set it, it uses another item's textview.</p>

<pre><code> if(!expiryDateText.isNull() &amp;&amp; expiresIn != null){
        long noDays = CompareDate.getDaysUntil(expiryDateText.getTextValue());
        if(noDays&lt;6){
            holder.expiresIn.setTextColor(Color.parseColor("#ff4444"));
        }
        holder.expiresIn.setText(String.valueOf(noDays) + " " + parent.getResources().getString(R.string.days_until_expiry));   
    }
    else {
        holder.expiresIn.setText("");
    }
</code></pre>
