title: ListView changing text color in text
body: <p>Hi im trying to change text color in cell of my list view but i can't because i get </p>
  
  <pre><code>11-25 20:22:37.176: E/AndroidRuntime(1338): FATAL EXCEPTION: Thread-116
  11-25 20:22:37.176: E/AndroidRuntime(1338): java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
  11-25 20:22:37.176: E/AndroidRuntime(1338):     at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
  11-25 20:22:37.176: E/AndroidRuntime(1338):     at java.util.ArrayList.get(ArrayList.java:304)
  11-25 20:22:37.176: E/AndroidRuntime(1338):     at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:225)
  11-25 20:22:37.176: E/AndroidRuntime(1338):     at morisson.Notowaniagieldowe.Tab2Fragment.getViewByPosition(Tab2Fragment.java:254)
  11-25 20:22:37.176: E/AndroidRuntime(1338):     at morisson.Notowaniagieldowe.Tab2Fragment$1.run(Tab2Fragment.java:123)
  </code></pre>
  
  <p>this is part code where i try to change color:</p>
  
  <pre><code>    int k = cash.size();
                      if(k&gt;0){
  
                          for(int l=0;l&lt;k;l++){
                              LinearLayout root = (LinearLayout) getViewByPosition(l+1,listView);
                              if(price&lt;m)
                              {
                                  ((TextView) root.findViewById(R.id.amount)).setTextColor(Color.RED);
  }
  }
  }
  </code></pre>
  
  <p>when i create linearlayout i have to increment l+1 because if I start from zero i change color at header. This is method I use to change return view:</p>
  
  <pre><code>public View getViewByPosition(int pos, ListView listView) {
      final int firstListItemPosition = listView.getFirstVisiblePosition();
      final int lastListItemPosition = firstListItemPosition + listView.getChildCount() - 1;
  
      if (pos &lt; firstListItemPosition || pos &gt; lastListItemPosition ) {
          return listView.getAdapter().getView(pos, null, listView);
      } else {
          final int childIndex = pos - firstListItemPosition;
          return listView.getChildAt(childIndex);
      }
  }
  </code></pre>
  
  <p>UPDATE:
  here is my adapter. I would add that when my app starts the list is empty, but the new thread which updates color is working.</p>
  
  <pre><code>public ListViewAdapter(Activity activity,ArrayList&lt;HashMap&lt;String, String&gt;&gt; list){
      super(activity, R.layout.lista_wlasnych_spolek, list);
      this.activity=activity;
      this.list=list;
  }
  
  @Override
  public int getCount() {
      // TODO Auto-generated method stub
      return list.size();
  }
  
  @Override
  public HashMap&lt;String, String&gt; getItem(int position) {
      // TODO Auto-generated method stub
      return list.get(position);
  }
  
  @Override
  public long getItemId(int position) {
      // TODO Auto-generated method stub
      return 0;
  }
  
  
  
  private int mColor = Color.BLACK;
  
  public void setColor(int color)
  {
      mColor = color;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
  ListViewHolder listViewHolder;
  if(convertView == null){
      listViewHolder = new ListViewHolder();
      convertView = activity.getLayoutInflater().inflate(R.layout.lista_wlasnych_spolek, null);
      listViewHolder.txtFirst = (TextView) convertView.findViewById(R.id.nazwa_spolki);
      listViewHolder.txtSecond = (TextView) convertView.findViewById(R.id.wartosc_akt);
      listViewHolder.txtThird = (TextView) convertView.findViewById(R.id.wartosc_kupna);
      listViewHolder.txtFourth = (TextView) convertView.findViewById(R.id.wartosc_calosci);
      convertView.setTag(listViewHolder);
  } else {
      listViewHolder = (ListViewHolder) convertView.getTag();
  }
  
  HashMap&lt;String, String&gt; map=list.get(position);
  listViewHolder.txtFirst.setText(map.get(FIRST_COLUMN));
  listViewHolder.txtSecond.setText(map.get(SECOND_COLUMN));
  listViewHolder.txtThird.setText(map.get(THIRD_COLUMN));
  listViewHolder.txtFourth.setText(map.get(FOURTH_COLUMN));
  
  
  TextView textViewFirst = (TextView) convertView.findViewById(R.id.nazwa_spolki);
  TextView textViewSecond = (TextView) convertView.findViewById(R.id.wartosc_akt);
  TextView textViewThird = (TextView) convertView.findViewById(R.id.wartosc_kupna);
  TextView textViewFourth = (TextView) convertView.findViewById(R.id.wartosc_calosci);
  
  textViewFirst.setTextColor(mColor);
  textViewSecond.setTextColor(mColor);
  textViewThird.setTextColor(mColor);
  textViewFourth.setTextColor(mColor);
  
  return convertView;
  }
  
  public class ListViewHolder {
      TextView txtFirst;
      TextView txtSecond;
      TextView txtThird;
      TextView txtFourth;
  }
  </code></pre>