title: Android: How to propagate click event to LinearLayout childs and change their drawable
body: <p>I would like to create a linear layout which would behave similarly to ImageButton.</p>
  
  <pre><code>&lt;LinearLayout
      android:id="@+id/container"
      style="?WidgetHomeIconContainer"&gt;            
  
      &lt;ImageView
          android:id="@+id/icon"
          style="?WidgetHomeIcon" /&gt;
  
      &lt;TextView
          android:id="@+id/title"
          style="?WidgetHomeLabel"             
          android:text="@string/title"
          android:textAppearance="?attr/TextHomeLabel" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>In styles of ImageView, TextView and LinearLayout, I set a selectors for all states.</p>
  
  <p>Now:</p>
  
  <ul>
  <li>when I click on ImageView (I tried it also with ImageButton) - it behaves correctly and the image is changed according the selector xml.</li>
  <li>when I click on LinearLayout - the linear layout is clicked, but the the ImageView and TextView don't change it's drawable/appearance</li>
  </ul>
  
  <p>So I would like to do the following. When I click on parent LinearLayout, I need to change all it's childs to pressed state.</p>
  
  <p>I tried to add following code to LinearLayout onClickListener to propagate the click:</p>
  
  <pre><code>@Override
  public void onClick(View v)
  {
      LinearLayout l = (LinearLayout) v;
      for(int i = 0; i &lt; l.getChildCount(); i++)
      {
          l.getChildAt(i).setClickable(true);
          l.getChildAt(i).performClick();
      }
  }
  </code></pre>
  
  <p>But it still reamins the same. Thank you very much for any help.</p>