access the rowlistview programmatically
<p>I am trying to change the alignment of the text in <code>ListView</code> programmatically instead of changing the xml file.</p>

<p>Here is my <code>row_listview.xml</code></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/textViewRowList" 
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:layout_width="fill_parent"
    android:textSize="20sp"
    android:paddingLeft="6dip"
    android:paddingRight="6dip" 
    android:gravity="left" 
    android:textColor="#330033"
    android:textStyle="bold"/&gt;
</code></pre>

<p>And <code>activity_main.xml</code> has following <code>ListView</code> defined there</p>

<pre><code>&lt;ListView
    android:id="@+id/listView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:divider="@null"
    android:dividerHeight="0dp"
    tools:listitem="@android:layout/simple_list_item_1" 
    android:background= "#FF6600"&gt;
 &lt;/ListView&gt;
</code></pre>

<p>So in my <code>mainactivity.java</code> I am trying to change the alignment of the text in listview at runtime when user clicks a button on my activity</p>

<pre><code>private ListView lv;
private TextView tvRowListView;
lv.setAdapter(new ArrayAdapter&lt;String&gt;(this,R.layout.row_listview, sampleStringArray));
tvRowListView = (TextView) findViewById(R.id.textViewRowList);
tvRowListView.setGravity(Gravity.CENTER);
</code></pre>

<p>The last line above is however throwing nullpointerexception. I am not sure why. Can someone throw some ideas/solutions here.</p>
