Source:
public View getView(int position, View convertView, ViewGroup parent) { ExpenseClaim claim = getItem(position); Resources resources = getContext().getResources(); if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.expense_claim_list_row, parent, false); } TextView destinationsTextView = (TextView)convertView.findViewById(R.id.tv_name); List<Destination> destinations = claim.getDestinations(); if ((destinations.size() > 0)&&(user.getLocation()!=null)){ Geolocation home = user.getLocation(); if (destinations.get(0).getLocation() != null) { Geolocation location = destinations.get(0).getLocation(); float[] results = new float[1]; double startLatitude = home.getLatitude(); double startLongitude = home.getLongitude(); double endLatitude = location.getLatitude(); double endLongitude = location.getLongitude(); Location.distanceBetween(startLatitude, startLongitude, endLatitude, endLongitude, results); float distanceBetween = results[0]; if (distanceBetween < 10000000.0) { convertView.setBackgroundColor(Color.BLUE); } else if (distanceBetween < 20000000.0) { convertView.setBackgroundColor(Color.CYAN); } else if (distanceBetween < 30000000.0) { convertView.setBackgroundColor(Color.GREEN); } else if (distanceBetween < 40000000.0) { convertView.setBackgroundColor(Color.YELLOW); } else { convertView.setBackgroundColor(Color.LTGRAY); } } } destinationsTextView.setText(buildDestinationsString(claim)); TextView dateTextView = (TextView)convertView.findViewById(R.id.tv_date); dateTextView.setText(DateFormat.getDateInstance().format(claim.getStartDate())); TextView amountsTextView = (TextView)convertView.findViewById(R.id.tv_amounts); String amounts = claim.getSummarizedAmounts(); if (amounts == null) { amounts = resources.getString(R.string.no_expenses); } amountsTextView.setText(amounts); TextView statusTextView = (TextView)convertView.findViewById(R.id.tv_status); statusTextView.setText(claim.getStatusString(resources)); statusTextView.setBackground(drawableForStatus(claim.getStatus(), resources)); return convertView; }

Target:
public View getView(int position, View convertView, ViewGroup parent) { ExpenseClaim claim = getItem(position); Resources resources = getContext().getResources(); if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.expense_claim_list_row, parent, false); } TextView destinationsTextView = (TextView)convertView.findViewById(R.id.tv_name); List<Destination> destinations = claim.getDestinations(); setColorCoding(destinations, convertView); destinationsTextView.setText(buildDestinationsString(claim)); TextView dateTextView = (TextView)convertView.findViewById(R.id.tv_date); dateTextView.setText(DateFormat.getDateInstance().format(claim.getStartDate())); TextView amountsTextView = (TextView)convertView.findViewById(R.id.tv_amounts); String amounts = claim.getSummarizedAmounts(); if (amounts == null) { amounts = resources.getString(R.string.no_expenses); } amountsTextView.setText(amounts); TextView statusTextView = (TextView)convertView.findViewById(R.id.tv_status); statusTextView.setText(claim.getStatusString(resources)); statusTextView.setBackground(drawableForStatus(claim.getStatus(), resources)); return convertView; }