I have a problem with pageviewer. I want to my page scroll every two seconds. I try something like this:
handler.postDelayed(new Runnable() {
public void run() {
viewPager.setCurrentItem(viewPager.getCurrentItem()+1, true);
}
},2000);
But it works only when I start activity. If i put this code to public void onPageSelected(int page) it works but I want to do when I click and manually scroll page I want to stop this handler but it doeasn’t work. How I can do that?
You should define your Runnable and Handler like this:
Make sure that you setup and tear down in your onPause & onResume methods
Finally, you’ll need to listen for a touch event on your viewpager so that you can set pagerMoved to true (which will then stop further automatic page transitions).