Nguyen  Minh Binh Nguyen Minh Binh - 6 months ago 70
Android Question

How to know viewpager is scroll left or right?

I am using ViewPager (support library). I want to know every time the ViewPager change the visible page, it is scrolling left or right.

Please give me a solution. Any recommend is welcome also.

Thanks

Answer

set setOnPageChangeListener to your ViewPager

and in

@Override
public void onPageSelected(int arg0) {
    if(lastPage>arg0)
      {//User Move to left}
    else(lastPage<arg0) 
     {//User Move to right}
      lastPage=arg0
}
Comments