Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I set the current item programatically in ViewPager2?

So in the the old ViewPager, you could set the initial position of the ViewPager using

viewPager.setCurrentItem(x)

How do you do that in ViewPager2?

like image 308
ColonD Avatar asked Aug 05 '26 13:08

ColonD


1 Answers

setCurrentItem is also an API on ViewPager2, so you should use that.

like image 145
ianhanniballake Avatar answered Aug 08 '26 02:08

ianhanniballake



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!