Crash/NPE upon setOnClickListener() after inflating
<p>My Android app is crashing when I call setOnClickListener(). Basically, what I have going on is an activity that is using ListView in one XML file, and an inflater in another XML file that consists of three ImageButtons. My images display fine, but when I call setOnClickListener, I get a NullPointerException and the app crashes. I can't figure out why, either.</p>

<p>Here's the gist of the activity:</p>

<pre><code>// Create an inflater to use another xml layout (the Facebook/Twitter/Instagram buttons)
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View footerView = inflater.inflate(R.layout.contacts_footer, null);

facebookButton = (ImageButton) findViewById(R.id.facebookButton);

// Commenting this chunk out has the images display perfectly fine
facebookButton.setOnClickListener(new OnClickListener() { // Crashes here
    public void onClick(View v) {
        // Open up the Facebook page when clicked
        facebookPage = new Intent(android.content.Intent.ACTION_VIEW);
        facebookPage.setData(Uri.parse(facebookURL));
        startActivity(facebookPage);
    }
});

listview.addFooterView(footerView);
listview.setAdapter(adapter);
</code></pre>

<p>Here's the main activity's 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:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@color/blackBackground" &gt;

    &lt;RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:background="@drawable/button_gradient" &gt;

        &lt;!-- Header --&gt;
        &lt;Button
            android:id="@+id/aboutButton"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerInParent="true"
            android:text="About"
            android:textColor="@color/whiteText" /&gt;

        &lt;TextView
            android:id="@+id/contactHeader"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="Contact"
            android:textColor="@color/whiteText" /&gt;
    &lt;/RelativeLayout&gt;

    &lt;!-- Listing --&gt;s
    &lt;RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" &gt;

        &lt;ListView
            android:id="@+id/contactItem"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:divider="@color/blackBackground"
            android:dividerHeight="15dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"&gt;
        &lt;/ListView&gt;

    &lt;/RelativeLayout&gt;

 &lt;/LinearLayout&gt;
</code></pre>

<p>Here's the footer's 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:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@color/blackBackground"
  android:id="@+id/buttonIcons"
  android:gravity="center_horizontal"&gt;

    &lt;LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/buttonIcons"
        android:gravity="center_horizontal"&gt;

        &lt;ImageButton
            android:id="@+id/facebookButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:paddingLeft="5dp"
            android:src="@drawable/facebook_icon" /&gt;

        &lt;ImageButton
            android:id="@+id/twitterButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:paddingLeft="5dp"
            android:src="@drawable/twitter_icon" /&gt;

        &lt;ImageButton
            android:id="@+id/instagramButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:paddingLeft="5dp"
            android:src="@drawable/instagram_icon" /&gt;

    &lt;/LinearLayout&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>And here's the stack trace:</p>

<pre><code>02-26 11:27:14.073: E/AndroidRuntime(875): FATAL EXCEPTION: main
02-26 11:27:14.073: E/AndroidRuntime(875): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.radio.app/org.radio.app.Contacts}: java.lang.NullPointerException
02-26 11:27:14.073: E/AndroidRuntime(875):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
02-26 11:27:14.073: E/AndroidRuntime(875):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
02-26 11:27:14.073: E/AndroidRuntime(875):  at android.app.ActivityThread.access$600(ActivityThread.java:130)
02-26 11:27:14.073: E/AndroidRuntime(875):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
02-26 11:27:14.073: E/AndroidRuntime(875):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-26 11:27:14.073: E/AndroidRuntime(875):  at android.os.Looper.loop(Looper.java:137)
02-26 11:27:14.073: E/AndroidRuntime(875):  at android.app.ActivityThread.main(ActivityThread.java:4745)
02-26 11:27:14.073: E/AndroidRuntime(875):  at java.lang.reflect.Method.invokeNative(Native Method)
02-26 11:27:14.073: E/AndroidRuntime(875):  at java.lang.reflect.Method.invoke(Method.java:511)
02-26 11:27:14.073: E/AndroidRuntime(875):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
02-26 11:27:14.073: E/AndroidRuntime(875):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-26 11:27:14.073: E/AndroidRuntime(875):  at dalvik.system.NativeStart.main(Native Method)
02-26 11:27:14.073: E/AndroidRuntime(875): Caused by: java.lang.NullPointerException
02-26 11:27:14.073: E/AndroidRuntime(875):  at org.radio.app.Contacts.onCreate(Contacts.java:127)
02-26 11:27:14.073: E/AndroidRuntime(875):  at android.app.Activity.performCreate(Activity.java:5008)
02-26 11:27:14.073: E/AndroidRuntime(875):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
02-26 11:27:14.073: E/AndroidRuntime(875):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
02-26 11:27:14.073: E/AndroidRuntime(875):  ... 11 more
</code></pre>

<p>Doing a Project -> Clean results in the same issue, and R.java has facebookButton defined.</p>

<p>I'm assuming if I can get this first button working, I can get my other two buttons working.</p>
