title: How to set an onClickListener on an included layout?
body: <p>I have a layout with an ImageButton that I included in several other layouts. </p>
  
  <p><strong>ImageButton Layout:</strong></p>
  
  <p><strong>call_cancelled.xml</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent" &gt;
  
  &lt;LinearLayout
      android:id="@+id/callEndLayout"
      android:layout_width="70dp"
      android:layout_height="70dp"
      android:height="70dip"
      android:orientation="horizontal"
      android:paddingBottom="5dp"
      android:paddingTop="5dp" &gt;
  
      &lt;ImageButton
          android:id="@+id/phoneEnd"
          android:layout_width="63dp"
          android:layout_height="63dp"
          android:paddingBottom="7dp"
          android:background="@drawable/phone_cancelled"  /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>My include:</strong></p>
  
  <pre><code>  &lt;include
     android:id="@+id/includeCallEnd0"
     android:layout_width="70dp"
     android:layout_height="70dp"
     android:layout_alignBottom="@+id/include"
     android:layout_alignParentRight="true"
     layout="@layout/call_cancelled" /&gt;
  </code></pre>
  
  <p>For this includes I need a onClickListener when it's pressed.
  <strong>I tried this:</strong></p>
  
  <pre><code>View endcall0 = (View) findViewById(R.id.includeCallEnd0);
  
   endcall0.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View arg0) {
  
              Intent callIntent = new Intent(Intent.ACTION_CALL_BUTTON);
              startActivity(callIntent);
  
              int id = viewFlipper.getDisplayedChild();
  
              if (id == 0) {
                  hideSoftKeyboard();
              }
          }
       });
  </code></pre>
  
  <p>But it doesn't work.
  Does anybody know the solution?</p>