title: How to add OnClickListener to image button in the ListView Header in Android?
body: <p>I have added a custom header to the ListView in android. The layout xml file for Header contains an Image button. How can I add an OnClickListener to this ImageButton</p>
  
  <p>Header Layout File</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="horizontal"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" android:background="#336699"&gt;
  
  &lt;ImageButton
      android:id="@+id/imageButton1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:src="@drawable/add" /&gt;
  
  
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Code for binding the ListView (I have created a custom Adapter)</p>
  
  <pre><code> ListView listView1 = (ListView) findViewById(R.id.listView1);
      LocationAdapter adapter = new LocationAdapter(this,R.layout.listrow,webresult);
      View header = (View)getLayoutInflater().inflate(R.layout.listheader, null);
      listView1.addHeaderView(header);
      listView1.setAdapter(adapter);
  </code></pre>