how do I add items to listview dynamically in android
<p>Can anybody help me? I'm trying to create a ListView in Android, and I'm trying to load items into it using code (not using XML)</p>

<p>Here's the code that I have so far</p>

<pre><code>tweetList = (ListView)this.findViewById(R.id.tweetListView);
        TextView tv;
        for(int i=0;i&lt;20;i++)
        {
            tv = new TextView(this);
            tv.setText("I'm a textView");
            tweetList.addHeaderView(tv);

        }

        tweetList.invalidate();
</code></pre>

<p>What am I doing wrong? The items are not showing in runtime</p>

<p>EDIT: I changed the code as per the answers below and here's the code I have now</p>

<pre><code> tweetList = (ListView)this.findViewById(R.id.tweetListView);
        ArrayAdapter&lt;TextView&gt; aa = new ArrayAdapter&lt;TextView&gt;(this, R.id.tweetListView);
        tweetList.setAdapter(aa);
        TextView tv;
        for(int i=0;i&lt;20;i++)
        {
            tv = new TextView(this);
            tv.setText("I'm a textView");
            //tweetList.addHeaderView(tv);

            aa.add(tv);

        }

        tweetList.invalidate();
</code></pre>

<p>I'm getting an exception now</p>

<pre><code>11-10 01:32:16.002: ERROR/AndroidRuntime(867): android.content.res.Resources$NotFoundException: Resource ID #0x7f050030 type #0x12 is not valid
</code></pre>

<p>Why am I not able to add them dynamically now?</p>
