title: How to replace fragment that is loaded by navigationView
body: <p>I have a navigation view that loads some fragments depending on which is pressed. In one of the fragments, I want to have a button, which when it is pressed, the fragment changes from the one loaded by the navigation view to a different fragment. I have tried using </p>
  
  <pre><code>ProfileEditFragment pef = new ProfileEditFragment();
  FragmentManager fm = getSupportFragmentManager();
  fm.beginTransaction().remove(pef).replace(R.id.drawer_layout, pef, "Fragment")
                  .addToBackStack(null).commit();
  </code></pre>
  
  <p>When I do this, it loads the other fragment on top of the current fragment, rather than replace it, even though I used the replace function. How do I fix this?</p>