title: how to replace fragments on tab?
body: <p>I have an activity with 2 tabs. What im trying to do is to replace between 2 fragments when each tab is pressesd. I also have 2 fragments: fragmentOne and fragmentTwo.When tab one is pressed i want to show fragmentOne and when tab two is pressed i want to show fragmentTwo. 
  I'm not sure if i should create a container layout in the activity and there add the fragmentOne and fragmentTwo, or maybe there is another other way to do it?</p>
  
  <p><strong>here is my code</strong></p>
  
  <pre><code>    public class InboxActivity extends AppCompatActivity {
  private TabLayout tabLayout;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_inbox);
  
      tabLayout = (TabLayout)findViewById(R.id.tabLayout);
  
      tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
              Fragment fragment;
              int position = tab.getPosition();
              //requests = position - 0
              //invitations = position - 1
              switch (position){
                  case 0:
                       break;
                  case 1:
                      break;
              }
          }
  
          @Override
          public void onTabUnselected(TabLayout.Tab tab) {
  
          }
  
          @Override
          public void onTabReselected(TabLayout.Tab tab) {
  
          }
      });
  }
  </code></pre>
  
  <p>when case is 0 i want to show fragmentOne </p>
  
  <p>when case i 1 i want to show fragmentTwo</p>
  
  <p>How should i do that?</p>