Forcing animation on ViewPager
I'd like to force the animation triggered by the finger-swipe on a ViewPager - something like, when I press a button ou开发者_运维问答tside the ViewPager, it does the fancy animation. I've tried something like:
myPagerAdapter.instantiateItem(myPager, requested_view_id)
myPager.computeScroll()
myPager.invalidate()
But it didn't work.
Any ideas?
Thanks!
If you just want to have a button or another event move to the "next page" or "previous page" in the ViewPager
use ViewPager.setCurrentItem(int item)
. This will also show the animation. You will just need to keep track of the current item yourself and then setCurrentItem(numCurrentItem + 1)
.
精彩评论