title: How to let click event pass to container in android?
body: <p>I have a table of <code>FrameLayout</code> where each frame contains either an <code>ImageView</code> or a <code>TextView</code>. Regardless of content in the frame I want the <code>onClick</code> event to be detected by the <code>OnClickListener</code> set on the frame.</p>
  
  <p>How can I achieve this?</p>
  
  <p>This is some of my layout, I got a total of 5 rows (Here's only shown 1).
  As described above I have 5 FrameLayouts in each row, each containing a TextView. I am not able to put my OnClickListener on the TextView since this may be changed to an ImageView at runtime. Therefore i want the OnClickListener on the FrameLayout.</p>
  
  <p>It seems that the content of the FrameLayout is preventing it from detecting the click event.</p>
  
  <pre><code>    &lt;TableLayout
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:id="@+id/gateContainer"
          android:stretchColumns="*"&gt;
  
          &lt;TableRow
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:layout_gravity="center"&gt;
  
              &lt;FrameLayout
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:id="@+id/door1"
                  android:clickable="true"&gt;
  
                  &lt;TextView
                      android:layout_width="fill_parent"
                      android:layout_height="fill_parent"
                      android:text="New Text"
                      android:id="@+id/textView"
                      android:layout_gravity="center" /&gt;
  
              &lt;/FrameLayout&gt;
  
              &lt;FrameLayout
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:id="@+id/door2" &gt;
  
                  &lt;TextView
                      android:layout_width="fill_parent"
                      android:layout_height="fill_parent"
                      android:text="New Text"
                      android:id="@+id/textView5"
                      android:layout_gravity="center" /&gt;
              &lt;/FrameLayout&gt;
  
              &lt;FrameLayout
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:id="@+id/door3" &gt;
  
                  &lt;TextView
                      android:layout_width="fill_parent"
                      android:layout_height="fill_parent"
                      android:text="New Text"
                      android:id="@+id/textView4"
                      android:layout_gravity="center"/&gt;
              &lt;/FrameLayout&gt;
       &lt;/TableLayout&gt;
  </code></pre>
  
  <p>Here is an example of how i set the OnClickListeners:</p>
  
  <pre><code>        View.OnClickListener clickListener = new View.OnClickListener() {
              @Override
              public void onClick(View v){
                  // do something
              }
          };
  
          TableLayout tableLayout = (TableLayout) findViewById(R.id.gateContainer);
          // Go through all TableRows
          for (int i = 0; i &lt; tableLayout.getChildCount(); i++){
              TableRow tableRow = (TableRow) tableLayout.getChildAt(i);
              // Set listener for each FrameView
              for (int j = 0; j &lt; tableRow.getChildCount(); j++){
                  FrameLayout frame = (FrameLayout) tableRow.getChildAt(j);
  
                  frame.setOnClickListener(clickListener);
              }
          }
  </code></pre>