title: Changing Fragments. Why does it not work
body: <p>I got this Code for changing Fragments with a Navigation drawer in Android Java. Simply followed official Googles Dev Posts and other pages, but it still doesn't work. Just the Header of the page changes but not the layout. Tell me please why, i wouldn't be asking if i havent tried a lot and read other Posts.</p>
  
  <p>So here's my Code:
  In MainActivity Java file</p>
  
  <pre><code>@Override
      public boolean onNavigationItemSelected(MenuItem item) {
          int id = item.getItemId();
          Fragment f = null;
          Class fClass = null;
          // Tasklist
          if (id == R.id.nav_drawer_main_tasklist) {
              fClass = TaskList.class;
          }
      try{
              f=(Fragment) fClass.newInstance();
          }catch (Exception e){
              e.printStackTrace();
          }
          FragmentManager fragmentManager = getFragmentManager();
          fragmentManager.beginTransaction().replace(R.id.frame_main,f).commit();
  
          item.setChecked(true);
          setTitle(item.getTitle());
          // Drawer
          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawerlayout_main);
          drawer.closeDrawer(GravityCompat.START
  
  );
  </code></pre>
  
  <p>in TaskList Java</p>
  
  <pre><code>public class TaskList extends Fragment {
  
  View view;
  
  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
      view = inflater.inflate(R.layout.activity_main_tasklist, container, false);
      return super.onCreateView(inflater, container, savedInstanceState);
  
  }
  </code></pre>
  
  <p>in tasklists XML file</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"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"
      tools:context="***"&gt;
  
      &lt;android.support.design.widget.FloatingActionButton
          android:id="@+id/fab_main_createtask"
  
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_alignParentEnd="true"
          android:layout_alignParentRight="true"
          android:layout_gravity="bottom|end"
          android:onClick="fab_main_createtask_onClick"
          app:srcCompat="@drawable/ic_add_white_24dp"
          tools:layout_editor_absoluteX="0dp"
          tools:layout_editor_absoluteY="0dp" /&gt;
  
      &lt;LinearLayout
          android:layout_width="0dp"
          android:layout_height="0dp"
          android:orientation="horizontal"
          tools:layout_editor_absoluteX="8dp"
          tools:layout_editor_absoluteY="8dp"&gt;
  
  
  
      &lt;/LinearLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>