OnClick in a CardView <include> layout <p>I have a xml that contains some <code>CardView</code> <code>&lt;include&gt;</code>, I want to set <code>onClick</code> in the <code>CardView</code> includes to open an <code>Activity</code> in my project. I tried to set the <code>onClick</code> in the <code>CardView</code> layout as you will see in the code below, it opens normally but triggers an error sometimes and the application stops. How can I set the <code>onClick</code> in this include?</p> <p>This is the <code>&lt;include&gt;</code> in my xml</p> <pre><code> &lt;include layout="@layout/view_caderno" android:id="@+id/view_caderno" /&gt; </code></pre> <p>and here is the <strong>CardView</strong></p> <pre><code>&lt;android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/card_view" android:layout_width="match_parent" android:layout_height="wrap_content" card_view:cardCornerRadius="10dp" card_view:cardElevation="15dp" android:layout_margin="5dp" android:onClick="Caderno" &gt; &lt;RelativeLayout android:layout_width="match_parent" android:layout_margin="2dp" android:layout_height="match_parent"&gt; &lt;ImageView android:id="@+id/pic1" android:layout_width="100dp" android:layout_height="135dp" android:scaleType="centerCrop" android:padding="5dp" android:src="@drawable/note" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" /&gt; &lt;TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/pic1" android:maxLines="3" android:text="Diário" android:padding="10dp" android:textColor="#222" android:textStyle="bold" android:textSize="22dp" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/title" android:maxLines="3" android:padding="5dp" android:drawableRight="@drawable/baby2" android:text="@string/diário" android:textColor="#666" android:textSize="14dp" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p></p>