title: How to change the viewpager under tablayout when I click the NavigationView item?
body: <h1>My UI contains content part and navigation part. The content part contains a Toolbar,a tablayout and a viewpager.It looks like</h1>
  
  <p><img src="https://i.stack.imgur.com/VZuYc.jpg" alt="The body content is a tablayout wrap a viewpager">
  <img src="https://i.stack.imgur.com/PozYA.jpg" alt="The NavigationView with Items"></p>
  
  <h1>My Work Flow</h1>
  
  <p>When I click the item in NavigationView, the UI replace the fragment in viewpager with other new fragment by call the following "setUpTab" method. The core codes is :</p>
  
  <pre><code>public void setUpTab(int id){
      adapter.clear();
      switch (id){
          case R.id.nav_home:
              adapter.addFragment(new EventFragment(),"Events");
              adapter.addFragment(new OwnRepoFragment(),"Repository");
              adapter.addFragment(new ContributeRepoFragment(),"Contribute");
              break;
          case R.id.nav_friends:
              adapter.addFragment(new FollowerFragment(),"Follower");
              adapter.addFragment(new FollowingFragment(),"Following");
              break;
          case R.id.nav_gist:
              break;
          case R.id.nav_setting:
              break;
          case R.id.nav_about:
              break;
      }
      adapter.notifyDataSetChanged();
      tab.setupWithViewPager(viewpager);
  ｝
   static class Adapter extends FragmentPagerAdapter {
      private final List&lt;Fragment&gt; mFragments = new ArrayList&lt;&gt;();
      private final List&lt;String&gt; mFragmentTitles = new ArrayList&lt;&gt;();
  
      public Adapter(FragmentManager fm) {
          super(fm);
      }
  
      public void addFragment(Fragment fragment, String title) {
          mFragments.add(fragment);
          mFragmentTitles.add(title);
      }
      public void clear(){
          mFragments.clear();;
          mFragmentTitles.clear();;
      }
  
  
      @Override
      public Fragment getItem(int position) {
          return mFragments.get(position);
      }
  
      @Override
      public int getCount() {
          return mFragments.size();
      }
  
      @Override
      public CharSequence getPageTitle(int position) {
          return mFragmentTitles.get(position);
      }
  }
  </code></pre>
  
  <h1>Question</h1>
  
  <p>I want to load data when a fragment is insert into the viewpager again(The insertion happens when i call "adapter.addFragment()").
  And I start the data-loading Thread in the life cycle method.But it seems that the life Cycle Methods(onCreate,onResume) are not always called.So I fail to get the chance to start the data-loading Thread.</p>
  
  <p>How can I replace the fragment in viewpager and make the fragment go through the normal life cycle methods:onCreate,onCreateView,onResume ?</p>