title: Fragment return null in viewPager.setOnPageChangeListener()
body: <p>I have a main activity called GuivActivity that uses viewPager to switch between two fragments (listFragment and SearchFragment). But when I try to get Fragment by id inside onPageSelected, it returns null. </p>
  
  <p>All I want to do here is to restart the loader in ListFragment so that every time when I come back I will have most updated data.</p>
  
  <p>in GuivActivity.java</p>
  
  <pre><code>@Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.activity_guiv);
  
          viewPager = (ViewPager)findViewById(R.id.viewpager);
          indicator = (TitlePageIndicator) findViewById(R.id.titleindicator);
          pagerAdapter = new PagerAdapter(getSupportFragmentManager());
          viewPager.setAdapter(pagerAdapter);
          indicator.setViewPager(viewPager);
          indicator.setOnPageChangeListener(listener);
      }
     ViewPager.OnPageChangeListener listener = new ViewPager.SimpleOnPageChangeListener(){
         @Override
         public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
  
         }
         @Override
         public void onPageSelected(int position) {
  
             switch (position){
                 case 0:
                     FragmentManager fm = getSupportFragmentManager();
                     ListFragment listFragment = (ListFragment) fm.findFragmentById(R.id.list_fragment_id);
  
                 case 1:
  
                 default:
                     break;
             }
         }
  
         @Override
         public void onPageScrollStateChanged(int state) {
  
         }
     };
  </code></pre>
  
  <p>in ListFragment.java</p>
  
  <pre><code>@Override
  public void onResume() {
      Message.message(mContext,"on resumed called");
      getLoaderManager().restartLoader(LIST_LOADER,null,this);
      super.onResume();
  }
  </code></pre>
  
  <p>in GuivActivity.xml</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"&gt;
  
  
  &lt;com.viewpagerindicator.TitlePageIndicator
      android:id="@+id/titleindicator"
      android:layout_height="wrap_content"
      android:layout_width="fill_parent" /&gt;
  
  &lt;android.support.v4.view.ViewPager
      android:id="@+id/viewpager"
      android:layout_width="match_parent"
      android:layout_height="0px"
      android:layout_weight="1"
      android:background="@android:color/white"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>in the fragment adatper</p>
  
  <pre><code> @Override
  public Fragment getItem(int position) {
      switch(position){
          case 0:
              return new ListFragment();
          case 1:
              return new SearchFragment();
          default:
              break;
      }
  
      return null;
  }
  </code></pre>