title: How to make LinearLayouts clickable
body: <p>I have a layout which is inherited from LinearLayout, I have this Custom View on MainActivity.</p>
  
  <p>My problem is the <strong><em>OnLongTouch</em></strong> won't work when I put this <strong><em>Custom View</em></strong> on an <strong><em>Activity</em></strong> and it seems my <strong><em>custom view</em></strong> is <strong><em>not clickable</em></strong>!</p>
  
  <p><strong>Layout code:</strong></p>
  
  <pre><code>public class AliLayout extends LinearLayout {
  
      public AliLayout(Context context, AttributeSet attrs) {
          super(context, attrs);
  
  
  
          if(! isInEditMode()){
  
              final AliLayout ly2 = this;//(AliLayout)findViewById(R.layout.ali_layout);
  
  
              ly2.setOnLongClickListener(new View.OnLongClickListener() {
  
                  @Override
                  public boolean onLongClick(View arg0) {
                      // TODO Auto-generated method stub
                      ly2.setTitle("Hello world!");
                      return false;
                  }
              });     
  
          }
      }
  
      @Override
      protected void onFinishInflate() {
          super.onFinishInflate();
          LayoutInflater.from(this.getContext()).inflate(R.layout.ali_layout,
                  this);
  
      }
  
  
      public void setTitle(String txt) {
          TextView tv = (TextView) findViewById(R.id.textView1);
          tv.setText(txt);
      }
  
  }
  </code></pre>
  
  <p><strong>inflated xml:</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/layout1"
      android:layout_width="200dp"
      android:layout_height="200dp"
      android:layout_alignParentBottom="true"
      android:layout_alignParentLeft="true"
      android:layout_marginBottom="68dp"
      android:layout_marginLeft="40dp"
      android:background="#E0D641"
      android:clickable="true"
      android:longClickable="true"
      android:orientation="vertical" &gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Large Text"
          android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
      &lt;TextView
          android:id="@+id/textView2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Large Text"
          android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
      &lt;Button
          android:id="@+id/button2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Button" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>MainActivity:</strong></p>
  
  <pre><code>&lt;RelativeLayout 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"
      android:clickable="true"
      android:longClickable="true"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context=".MainActivity" &gt;
  
      &lt;com.example.component.AliLayout
          android:id="@+id/ali1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_marginTop="22dp" &gt;
      &lt;/com.example.component.AliLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>