title: Replace fragments in FrameLayout layout
body: <p>I have tried every tutorial on the first google page about android fragments, but I can't get anything to work.</p>
  
  <p>So I have one navigation bar activity, <code>MainActivity</code>.
  Now I'd like to change fragments on a click in the drawer.</p>
  
  <p>In my <code>content_main</code> (default fragment in the <code>MainActivity</code> activity), I have a framelayout that I wish to put the fragments in. I have the following fragments: <code>fragment_main</code>, <code>fragment_one</code> and <code>fragment_two</code>. And I wish to show these when I click on a button in the nav drawer.</p>
  
  <p>The reason I want to use fragments is so that the nav drawer will stay on top.</p>
  
  <p>Thanks in advance!</p>
  
  <p>Edit: Here is the function I'll use to change fragments:<br>
  It's just to test, not finished.</p>
  
  <pre><code>public void setFragment() {
      android.support.v4.app.FragmentTransaction transaction;
      transaction = getSupportFragmentManager().beginTransaction();
      transaction.replace(R.id.fragment_container, new LoginFragment());
      transaction.commit();
  }
  </code></pre>