Android Display a list using ListView
<p>I am trying to display a list after clicking a button on Android.</p>

<p>This is my code:</p>

<pre><code>//Button after clicking should display a list
final Button button4 = (Button) findViewById(R.id.widget30);
button4.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {

        Intent myIntent = new Intent(v.getContext(), TestListActivities.class);
        startActivity(myIntent);

    }

    public class TestListActivities extends Activity {
        String[] listItems = {"Game1", "Game2", 
                              "Game3", "Game4"};
        public ListView la;

        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main2);
            la=(ListView)findViewById(R.id.widget50);
            la.setAdapter(new ArrayAdapter&lt;String&gt;(this, 
            R.layout.main2, listItems));
        }
}
</code></pre>

<p>My XML file is:</p>

<pre><code>?xml version="1.0" encoding="utf-8"?
AbsoluteLayout
android:id="@+id/widget28"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"

ListView
android:id="@+id/widget50"
android:layout_width="wrap_content"
android:layout_height="wrap_content" 

AbsoluteLayoute
</code></pre>

<p>But when I click the button, the application is forced to close and it crashes.</p>

<p>Manifest file


    </p>

<pre><code>&lt;application android:icon="@drawable/icon" android:label="BAM! Pong" android:debuggable="true"&gt;


&lt;activity android:name=".GUI" android:label="@string/app_name" android:screenOrientation="portrait"&gt;&lt;intent-filter&gt;&lt;action android:name="android.intent.action.MAIN"&gt;&lt;/action&gt;
</code></pre>

<p>
</p>

<p>
</p>

<p>

</p>
