title: How to update views of viewpager on swipe - android
body: <p>I am using view-pager.In that I have three tabs : 1. History , 2. Main , 3. Map . </p>
  
  <p>I have stopwatch into main activity.When I press the start and then after stop at that time value of the stopwatch add into the sqlite DB. And into history activity I am fetching the value of stopwatch from DB and store into the listview. It's working perfect.</p>
  
  <p>But now I want the update the History activity when I swipe from the <strong>Main  > History</strong> so After press the stop button,I got the last value into listview of history activity.</p>
  
  <p>My question is <code>how can I update the view on swipe the viewpager?</code></p>
  
  <pre><code>public class SwipeyTabsSampleActivity extends FragmentActivity {
  
  private static final String [] TITLES = {
      "HISTORY", 
      "MAIN",
      "MAP"  
  
  };
  
  private SwipeyTabs mTabs;
  private ViewPager mViewPager;
  //Handler handler=new Handler();
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.activity_swipeytab);
  
      mViewPager = (ViewPager) findViewById(R.id.viewpager);
      mTabs = (SwipeyTabs) findViewById(R.id.swipeytabs);
  
      SwipeyTabsPagerAdapter adapter = new SwipeyTabsPagerAdapter(this,
              getSupportFragmentManager());
      mViewPager.setAdapter(adapter);
      mTabs.setAdapter(adapter);
      mViewPager.setOnPageChangeListener(mTabs);
      mViewPager.setCurrentItem(1); 
      mViewPager.setOffscreenPageLimit(3);
  
  
  }
  
   private class SwipeyTabsPagerAdapter extends FragmentPagerAdapter implements
          SwipeyTabsAdapter, ViewPager.OnPageChangeListener {
  
      private final Context mContext;
      ViewPager viewpager;
  
  
  
      public SwipeyTabsPagerAdapter(Context context, FragmentManager fm, ViewPager mViewPager) {
          super(fm);
  
          this.mContext = context;
          viewpager = mViewPager;
  
          //viewpager.setAdapter(this);
          viewpager.setOnPageChangeListener(this);
  
      }
  
      @Override
      public Fragment getItem(int position) {
  
           Fragment f = new Fragment();
  
          switch (position) {
          case 0:
              f = History.newInstance(position);
  
              break;
          case 1:
              f = Main.newInstance(position);
              break;
          case 2:
              f = Map.newInstance(position);
  
              break;
  
          }
          return f;
  
      }
  
      @Override
      public int getCount() {
          return TITLES.length;
      }
  
  
       @Override
          public void destroyItem(ViewGroup container, int position, Object object) {
  
              ViewPager pager = (ViewPager) container;
              View view = (View) object;
  
              pager.removeView(view);
          }
  
  
  
      public TextView getTab(final int position, SwipeyTabs root) {
          TextView view = (TextView) LayoutInflater.from(mContext).inflate(
                  R.layout.swipey_tab_indicator, root, false);
          view.setText(TITLES[position]);
          view.setOnClickListener(new OnClickListener() {
              public void onClick(View v) {
                  mViewPager.setCurrentItem(position);
  
              }
          });
  
          return view;
      }
  
      @Override
      public void onPageScrollStateChanged(int state) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void onPageSelected(int positiion) {
          // TODO Auto-generated method stub
  
      }
  
  }
  
  }
  </code></pre>