title: Android Custom list adapter- Color for each list entry
body: <p>I have a list of Android sensors in the UI. My whole application is a service and each sensor can be turned on/off by sending HTTP Post requests. Example, http ://IPaddress:port/accelerometer/on will turn on the accelerometer. My requirement is to change the color of the list entry to RED when the sensor is switched on and turn it to BLACK when the sensor is switched off. Multiple sensors can be turned on simultaneously.  I use the below code, but please let me know how can I change multiple sensor entries in the list? i.e, if 3 sensors are turned on, all the color of the entries in the list should  change to RED. Thanks in advance!</p>
  
  <pre><code>public View getView (int position, View convertView, ViewGroup parent)
  {
  View rowView = convertView;
  TextViewHolder holder = null;   
  if(rowView == null)
  {   
  LayoutInflater inflater = LayoutInflater.from(context);
  rowView = inflater.inflate(layoutResourceId, parent, false);
  holder = new TextViewHolder(); 
  holder.txt = (TextView)rowView.findViewById(R.id.txtTitle);
  rowView.setTag(holder);  
  }
  else{       
      holder = (TextViewHolder) rowView.getTag();     
  }
  if(values[position].contains(sensor) &amp;&amp; state[position])
  {
  ((TextView)rowView.findViewById(R.id.txtTitle)).setTextColor(Color.RED);
  ((TextView)rowView.findViewById(R.id.txtTitle)).setText(values[position]);  
  }  
  else if(values[position].contains(sensor) &amp;&amp; (!state[position]))
     {  ((TextView)rowView.findViewById(R.id.txtTitle)).setTextColor(Color.BLACK);
       ((TextView)rowView.findViewById(R.id.txtTitle)).setText(values[position]);
  }
  else
  {       
  holder.txt.setTextColor(Color.BLACK);
  holder.txt.setText(values[position]);    
  }  
  return rowView;
  }
  </code></pre>
  
  <p>UPDATE: I have 17 sensors in my list. But there are 2 sensors for gravity, linear acceleration etc. The getView() method iterates only for the first 10 entries and repeats those. </p>