title: How to remove Fragment from an Activity?
body: <p>I'm trying to remove a fragment from my MainActivity after clicking a choice in the slide menu. But I cannot find how to implement it.</p>
  
  <p>I looked online and found the <code>FragmentTransaction</code> class but I think I have the wrong implementation.</p>
  
  <p>MainActivity Java;</p>
  
  <pre><code> @Override
      public boolean onNavigationItemSelected(MenuItem item) {
          // Handle navigation view item clicks here.
          int id = item.getItemId();
  
          if (id == R.id.Technology) {
              FragmentTransaction.remove(R.layout.frag);
  
  
          } else if (id == R.id.Opinion) {
  
  
          } else if (id == R.id.travel) {
  
          } else if (id == R.id.politics) {
  
          }else if(id == R.id.Home){
          }
  
          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
          drawer.closeDrawer(GravityCompat.START);
          return true;
  </code></pre>
  
  <p>XML file for the main_content;</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout 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:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:background="#692f2f"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"
      tools:showIn="@layout/app_bar_main"&gt;
  
  
      &lt;fragment
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/fragment"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true"
          android:layout_marginTop="53dp"
          tools:layout="@layout/frag" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>