title: navigation drawer main activity content
body: <p>hi i have navigation drawer in my android application in the main activity java class and this is the code</p>
  
  <pre><code>    public class MainActivity extends AppCompatActivity
           implements NavigationView.OnNavigationItemSelectedListener {   
  
           @Override
           protected void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           setContentView(R.layout.activity_main);
  
           Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
           setSupportActionBar(toolbar);
  
           DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
           ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                   this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
           drawer.setDrawerListener(toggle);
           toggle.syncState();
  
           NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
           navigationView.setNavigationItemSelectedListener(this);
  
           //add this line to display menu1 when the activity is loaded
           displaySelectedScreen(R.id.nav_menu1);
       }
  
       @Override
       public void onBackPressed() {
           DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
           if (drawer.isDrawerOpen(GravityCompat.START)) {
               drawer.closeDrawer(GravityCompat.START);
           } else {
               super.onBackPressed();
           }
       }
  
       private void displaySelectedScreen(int itemId) {
  
           //creating fragment object
           Fragment fragment = null;
           DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
  
           //initializing the fragment object which is selected
           switch (itemId) {
               case R.id.nav_menu1:
                   fragment = new gallary();
                   break;
               case R.id.nav_menu2:
                   fragment = new about();
                   break;
               case R.id.nav_menu3:
                   fragment = new contact();
                   break;
           }
  
           //replacing the fragment
           if (fragment != null) {
               FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
               ft.replace(R.id.content_frame, fragment);
               ft.commit();
           }
  
           drawer.closeDrawer(GravityCompat.START);
       }
  
  
       @SuppressWarnings("StatementWithEmptyBody")
       @Override
       public boolean onNavigationItemSelected(MenuItem item) {
  
           //calling the method displayselectedscreen and passing the id of selected menu
           displaySelectedScreen(item.getItemId());
           //make this method blank
           return true;
       }
   }
  </code></pre>
  
  <p>and this is the main activity xml code</p>
  
  <pre><code>&lt;android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          xmlns:tools="http://schemas.android.com/tools"
          android:id="@+id/drawer_layout"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fitsSystemWindows="true"
          tools:openDrawer="start"&gt;
  
          &lt;include
              layout="@layout/app_bar_main"
              android:layout_width="match_parent"
              android:layout_height="match_parent" /&gt;
  
          &lt;android.support.design.widget.NavigationView
              android:id="@+id/nav_view"
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:layout_gravity="start"
              android:fitsSystemWindows="true"
              app:headerLayout="@layout/nav_header_main"
              app:menu="@menu/activity_main_drawer" /&gt;
  
      &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>so i want to add some content such an images and texts to main activity xml page of the app but when i add it in main content of navigation it looks good and everything okay but when i click on for example gallary fragment from the navigation drawer it took me to new page which has the content that i put in gallary xml but the problem is the content of main activity appear too with all fragment pages that i click from navigation drawer
  how can i make the content of each fragment appear without the content of main activity
  anyone understand me ? @_@</p>