Reputation: 25
I am using ViewPager with 4 pages. I need a code to navigate to the first page on specific events. Any idea how? The PagerAdapter has the methods setPrimaryItem, but I am uncertain how to use it. Another relevant question is how to trigger swiping the pager through code, I could use that to swipe all the way to the needed view, and I imagine it will also look better.
Upvotes: 0
Views: 294
Reputation: 15155
Just use mViewPager.setCurrentItem(1)
, this method will navigate to that page with the swipe animation.
Upvotes: 2