button onclicklistener error
<p>i'm getting this error when i try to run my app in the emulator (any android version): <strong>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.test/com.android.test.HomeScreen}: java.lang.NullPointerException</strong></p>

<p><strong>my question is:</strong> is this because in 2.2 there is no "golf button" in the layout, and in 3.0 there is?</p>

<p>this is my activity:</p>

<pre><code>public class HomeScreen extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.homescreen);

    Button basketball = (Button)findViewById(R.id.basketball);

    basketball.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
        Intent basketball = new Intent(HomeScreen.this, basketball.class);
        startActivity(basketball);
        }
    });

    Button golf = (Button)findViewById(R.id.golf);

    golf.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
        Intent golf = new Intent(HomeScreen.this, golf.class);
        startActivity(golf);
        }
    });
}
}
</code></pre>

<p>i got 2 layouts</p>

<p>layout 1: <strong>layout-normal-mdpi</strong> &lt;= running in 2.2</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/homescreen"&gt;

    &lt;Button
        android:id="@+id/basketball"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/basketbal"
        android:layout_marginTop="46dp"
        android:layout_marginRight="30dp"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"&gt;
    &lt;/Button&gt;
&lt;/RelativeLayout&gt;
</code></pre>

<p>layout 2: <strong>xlarge-port</strong> &lt;= running in 3.0</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/homescreen"&gt;

    &lt;Button
        android:id="@+id/basketball"
        android:background="@drawable/basketbal"
        android:layout_height="225dp"
        android:layout_width="225dp"
        android:layout_marginRight="70dp"
        android:layout_marginTop="90dp"
        android:layout_alignParentRight="true"&gt;
    &lt;/Button&gt;
    &lt;Button
        android:id="@+id/golf"
        android:background="@drawable/golf"
        android:layout_height="550dp"
        android:layout_width="211dp"
        android:layout_marginLeft="100dp"
        android:layout_marginTop="390dp"
        android:layout_alignParentLeft="true"&gt;
    &lt;/Button&gt;
&lt;/RelativeLayout&gt;
</code></pre>
