Android: onClick on LinearLayout with TextView and Button
        Posted  
        
            by 
                Terry
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Terry
        
        
        
        Published on 2013-10-30T15:43:20Z
        Indexed on 
            2013/10/30
            15:53 UTC
        
        
        Read the original article
        Hit count: 504
        
I have a Fragment that uses the following XML layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/card"
    android:clickable="true"
    android:onClick="editActions"
    android:orientation="vertical" >
    <TextView
        android:id="@+id/title"
        style="@style/CardTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:duplicateParentState="true"
        android:text="@string/title_workstation" />
    <Button
        android:id="@+id/factory_button_edit"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:duplicateParentState="true"
        android:text="@string/label_edit" />
</LinearLayout>
As you can see, I have an onClick parameter set on LinearLayout. Now on the TextView this one is triggered correctly, and on all empty area. Just on the Button it doesn't invoke the onClick method that I set.
Is this normal? What do I have to do so that the onClick method is invoked everywhere on the LinearLayout?
© Stack Overflow or respective owner