title: Dynamycally add multiple fragments in FrameLayout
body: <p>I'm am trying to add dynamycally multiple fragments I'm creating to a framelayout, using FragmentTransaction's add() method. Each time I try to do it, Fragments are just replacing one an other.</p>
  
  <p>Here is my code : </p>
  
  <pre><code>public class FragmentMerchandSearch extends Fragment {
  
  
      public FragmentMerchandSearch() {
          // Required empty public constructor
      }
  
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          // Inflate the layout for this fragment
          View view = inflater.inflate(R.layout.fragment_merchand_search, container, false);
          FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
          for(int i = 0; i &lt; 10; i++){
              Fragment newFragment = new FragmentMerchandPresentation();
  
              ft.add(R.id.container_merchand_presentation_for_search, newFragment);
  
          }
          ft.commit();
  
          return view;
      }
  }
  </code></pre>
  
  <p>Here is the code of FragmentMerchandPresentation:</p>
  
  <pre><code>public class FragmentMerchandPresentation extends Fragment {
  
      public FragmentMerchandPresentation(){
  
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          // Inflate the layout for this fragment
          View view = inflater.inflate(R.layout.fragment_presentation_merchand, container, false);
  
  
          return view;
      }
  }
  </code></pre>
  
  <p>Here is XML of fragment_merchand_search:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent" android:layout_height="match_parent"&gt;
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;FrameLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/container_merchand_presentation_for_search"&gt;
  
          &lt;/FrameLayout&gt;
  
      &lt;/LinearLayout&gt;
  
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p>And XML of fragment_presentation_merchand:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Hey !"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>