title: Dynamically inflating a fragment using layout xml, cannot find the fragment
body: <p>I am trying to inflate a layout, which contains a fragment declared inside it. This layout is then added as a subview to a framelayout. Though the fragment gets inflated properly, i am not able to search for the fragment at all.</p>
  
  <pre><code>class Activity1 extends Activity {
     public void onCreate(...){
       setContentView(R.layout.container);
       mContainer = findViewId(R.id.container);
     }
  
     public void OnClick(...){
       LayoutInflater.from(this).inflate(R.layout.child, mContainer);
       Fragment f =getSupportFragmentManager().findFragmentById(R.id.container);
       //f is always null
    }
  }
  
  layout.container
   &lt;FrameLayout android:id="@+id/container" .../&gt;
  
  layout.child
   &lt;fragment android:name="com.example.child" .../&gt;
  </code></pre>
  
  <p>Am i missing something?</p>
  
  <p><strong>I think I found the issue,</strong> </p>
  
  <p>This is in fragmentmanager code</p>
  
  <pre><code>View parent = null;
  int containerId = parent != null ? parent.getId() : 0
  fragment.mFragmentId = id != 0 ? id : containerId;
  </code></pre>
  
  <p>So I guess inflating a fragment using layout inflater does not work the same way as adding a fragment using FragmentManager</p>