title: How to get 2 fragments in a single activity
body: <p>I am trying to use fragments in android and want to display <code>fragment1</code>  and <code>fragment2</code> together but with this code I am just getting the second fragment . How to get both fragments?    </p>
  
  <pre><code>    import android.app.Fragment;
      import android.app.FragmentManager;
      import android.app.FragmentTransaction;
      import android.support.v7.app.AppCompatActivity;
      import android.os.Bundle;
      import android.view.Display;
      import android.view.WindowManager;
  
      public class MainActivity extends AppCompatActivity {
  
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
  
  
              FragmentManager fm=getFragmentManager();
              FragmentTransaction ft= fm.beginTransaction();
  
  
  
                  Fragment1 f1 = new Fragment1();
                  ft.add(android.R.id.content, f1);
                 Fragment2 f2 = new Fragment2();
                  ft.add(android.R.id.content, f2);
  
          ft.commit();
          }
      }
  </code></pre>