title: Refresh on swiping tabs android
body: <p>I am using view pager and fragments. I have three swipable tabs. Each extend Fragment. I want them to refresh them on swipe. How to achieve this? Now when I swipe, the tab does not get refreshed.</p>
  
  <pre><code>public class Orders extends FragmentActivity implements
      ActionBar.TabListener {
  
  private ViewPager viewPager;
  private TabsPagerAdapter mAdapter;
  private ActionBar actionBar;
  // Tab titles
  private String[] tabs = { "Pending", "Completed", "Rejected" };
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_orders);
      this.setTitle((Html.fromHtml("&lt;font color=\"#ffffff\"&gt;" + "pharmeazy-mobile" + "&lt;/font&gt;")));
      // Initilization
      viewPager = (ViewPager)findViewById(R.id.pager1);
      mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
      actionBar=getActionBar();
      getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#69acdf")));
      viewPager.setAdapter(mAdapter);
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);        
  
      // Adding Tabs
      for (String tab_name : tabs) {
          actionBar.addTab(actionBar.newTab().setText(tab_name)
                  .setTabListener(this));
      }
  
      /**
       * on swiping the viewpager make respective tab selected
       * */
      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) {
  }
  
  @Override
  public void onTabSelected(Tab tab, FragmentTransaction ft) {
      // on tab selected
      // show respected fragment view
      viewPager.setCurrentItem(tab.getPosition());
  }
  
  @Override
  public void onTabUnselected(Tab tab, FragmentTransaction ft) {
  }
  </code></pre>
  
  <p>Please help</p>