title: How to refresh the ViewPager for every tab?
body: <p>I'm using ViewPager as a main layout and for individual pager views I use Fragments. The tabs are part of Action Bar.
  I wanna refresh the current tab with the refresh-button in my actionbar.</p>
  
  <p>My MainActivity.java </p>
  
  <pre><code>@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
  
      viewPager = (ViewPager) findViewById(R.id.pager);
      actionBar = getActionBar();
      mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
  
      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));
      }
  
      /**
       * 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);
              mAdapter.notifyDataSetChanged();
          }
  
          @Override
          public void onPageScrolled(int arg0, float arg1, int arg2) {
          }
  
          @Override
          public void onPageScrollStateChanged(int arg0) {
          }
      });
  }
  
  
  @Override
  public boolean onOptionsItemSelected(MenuItem menuItem)
  {     
      switch (menuItem.getItemId()) {
  
  
      case R.id.action_refresh:
  
           // code for the refresh             
  
          return true;
  
      default:
          this.finish();
  
          return super.onOptionsItemSelected(menuItem);
      }
      //startActivity(new Intent(this,PreviousActivity.class)); 
  }
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      MenuInflater inflater = getMenuInflater();
      inflater.inflate(R.menu.activity_actions, menu);
  
      return super.onCreateOptionsMenu(menu);
  }
  
  @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>This is one of my Tabs
  StartPage.java</p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
  
      View rootView = inflater.inflate(R.layout.startpage, container, false);
      return rootView;
  }
  
  
  
  @Override
  public void onTabReselected(Tab arg0, FragmentTransaction arg1) {
      // TODO Auto-generated method stub
  
  }
  @Override
  public void onTabSelected(Tab tab, FragmentTransaction ft) {
      // TODO Auto-generated method stub
  
  }
  @Override
  public void onTabUnselected(Tab tab, FragmentTransaction ft) {
      // TODO Auto-generated method stub
  
  }
  </code></pre>