title: dynamically adding multiple fragments to my activity layout
body: <p>I have a linearlayout with no child views </p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal" &gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>and i want to dynamically add one fragment or two fragments as per requirements in it.
  i am aware of adding one fragment to it but how can i add two to fragments dynamically to it.
  I have two fragments and within each fragment i write the following oncreateview</p>
  
  <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          //return super.onCreateView(inflater, container, savedInstanceState);
          View v=inflater.inflate(R.layout.frag1, container, false);
          v.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
  
          return v; 
      }
  </code></pre>
  
  <p>i am trying to add using the following code but the second fragment is coming over the first one.</p>
  
  <pre><code>FragmentTransaction ft=fm.beginTransaction();
          frag1 f=new frag1();
          frag2 ff=new frag2();
  
  
          ft.add(android.R.id.content, f);
          ft.add(android.R.id.content, ff);
  
          ft.commit();
  </code></pre>
  
  <p>kindly update how this can be done.
  thanks</p>