Why don't inflated views respond to click listeners? <p>I'm trying to set a click listener for a button in my layout. The click listener is only triggered when I call findViewById() directly, and not when I take the view from the inflated layout:</p> <pre><code>public class MyActivity extends Activity implements View.OnClickListener { private static final String TAG = "MyActivity"; @Override public void onCreate( Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); setContentView( R.layout.test ); Button button = (Button)findViewById( R.id.mybutton ); button.setOnClickListener( this ); LayoutInflater inflater = (LayoutInflater)getSystemService( Context.LAYOUT_INFLATER_SERVICE ); ViewGroup rootLayout = (ViewGroup)inflater.inflate( R.layout.test, (ViewGroup)findViewById( R.id.myroot ), false ); rootLayout.getChildAt( 0 ).setOnClickListener( new View.OnClickListener() { @Override public void onClick( View v ) { Log.d( TAG, "Click from inflated view" ); } } ); } @Override public void onClick( View v ) { Log.d( TAG, "Click" ); } } </code></pre> <p>Here is my layout:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/myroot" android:orientation="vertical" android:layout_width="fill_parent" android:background="#ffffff" android:layout_height="fill_parent"&gt; &lt;Button android:text="Button" android:id="@+id/mybutton" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt;&lt;/Button&gt; &lt;/LinearLayout&gt; </code></pre> <p>Why is this? I only get the click event from the first method and not from the inflated view.</p>