title: How to refresh a fragment in a viewpager?
body: <p>I know there are already some questions to this problem. But I am really new in Android and ecspecially to <code>Fragments</code> and <code>Viewpager</code>. Pls have passion with me. I didn't found a answer which fits to my code.</p>
  
  <p>I dont know how to refresh a fragment or reload it when it's "active" again.</p>
  
  <p><strong>TabsPagerAdapter.java:</strong></p>
  
  <pre><code>public class TabsPagerAdapter extends FragmentPagerAdapter{
  
  
      public TabsPagerAdapter(FragmentManager fm){
          super(fm);
      }
  
      @Override
      public Fragment getItem(int index) {
  
          switch (index) {
          case 0:
  
              return new KFZFragment();
          case 1:
  
              return new LogFragment();
          case 2:
  
              return new TrackFragment();
          }
  
          return null;
      }
  
      @Override
      public int getCount() {
          // get item count - equal to number of tabs
          return 3;
      }
  
  }
  </code></pre>
  
  <p>I have this 3 Fragments (<code>KFZFragment,LogFragment,TrackFragment</code>) and on the <code>TrackFragment</code> I calculate some data and this data should be display in a ListView in <code>LogFragment</code>.
  But when I change to LogFragment it's not the latest data. So it doesnt refresh.</p>
  
  <p>Now how should I modify my code to refresh the fragments when it's "active"?</p>
  
  <p><strong>MainActivityFragment.java:</strong></p>
  
  <pre><code>public class MainActivityFragment extends FragmentActivity implements ActionBar.TabListener{
  
      private ViewPager viewPager;
      private TabsPagerAdapter mAdapter;
      private ActionBar actionBar;
      List&lt;Fragment&gt; fragments;
  
      private String[] tabs = { "KFZ", "Fahrten Log", "Kosten Track" };
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main_fragment);
  
          // Initilization
          viewPager = (ViewPager) findViewById(R.id.pager);
          actionBar = getActionBar();
          mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
  
         fragments = new Vector&lt;Fragment&gt;();
          fragments.add(Fragment.instantiate(this, KFZFragment.class.getName(),savedInstanceState));
          fragments.add(Fragment.instantiate(this, LogFragment.class.getName(),savedInstanceState));
  
          viewPager.setAdapter(mAdapter);
          actionBar.setHomeButtonEnabled(false);
          actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);        
  
          // Adding Tabs
          for (String tab_name : tabs) {
              actionBar.addTab(actionBar.newTab().setText(tab_name)
                      .setTabListener(this));
          }
  
          viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
  
              @Override
              public void onPageSelected(int position) {
                  // on changing the page
                  // make respected tab selected
                  actionBar.setSelectedNavigationItem(position);
  
              }
  
              @Override
              public void onPageScrolled(int arg0, float arg1, int arg2) {
              }
  
              @Override
              public void onPageScrollStateChanged(int arg0) {
              }
          });
      }   
      @Override
      public void onTabReselected(Tab tab, FragmentTransaction ft) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void onTabSelected(Tab tab, FragmentTransaction ft) {
          viewPager.setCurrentItem(tab.getPosition());
  
      }
  
      @Override
      public void onTabUnselected(Tab tab, FragmentTransaction ft) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public boolean onKeyDown(int keyCode, KeyEvent event) {
          if (keyCode == KeyEvent.KEYCODE_BACK) {
  
  
          }
          return super.onKeyDown(keyCode, event);
      }
  
  }
  </code></pre>
  
  <p>Pls help me out.</p>