Help me change TextView color dynamically?
<p>I would like to know how to change the color of a TextView dynamically.  It seems there is some stuff out there but now quite what I'm looking for.. what i'm doing here is iterating an array and if its "+" i want the text to be greem if its "-" i want the text to be red, the problem is that i'm getting null pointer error at ct.setTextColor(.....) anyone have any idea why?  </p>

<p>here is the xml:</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="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:padding="6dip"&gt;
    &lt;ImageView
        android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_marginRight="6dip"
        android:src="@drawable/icon" /&gt;
    &lt;LinearLayout
        android:orientation="vertical"
        android:layout_width="0dip"
        android:layout_weight="1"
        android:layout_height="fill_parent"&gt;
        &lt;TextView
            android:id="@+id/tt"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1"
            android:gravity="center_vertical"
        /&gt;
        &lt;TextView
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1" 
            android:id="@+id/bt"
            android:singleLine="true"
            android:ellipsize="marquee"
        /&gt;
    &lt;/LinearLayout&gt;
     &lt;TextView
        android:id="@+id/pm"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_gravity="right"
        android:text="-"

        android:textSize="30sp"
        android:textStyle="bold"
        /&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>and the code snippit</p>

<pre><code>    int c = count; 
    ind = (count);
    j=0;
    TextView ct = (TextView)findViewById(R.id.pm);
    funkAdapter = (new ArrayAdapter&lt;String&gt;(this, R.layout.rowneg, R.id.pm));
    String[] tmpAry= new String[count]; 
    for (int i = 0; i &lt; ind; i = i+2){
         tmpAry[j] = dataAryArray[i];

        if (tmpAry[j].equals("-")){
        funkAdapter.add(tmpAry[j]);
        ct.setTextColor(Color.RED);
        }else{
            funkAdapter.add(tmpAry[j]);
            ct.setTextColor(Color.GREEN);

        }
        j++;
    }
    setListAdapter(funkAdapter);
</code></pre>
