如何在 ViewPager2 中以编程方式设置当前项目? [英] how do I set the current item programatically in ViewPager2?

查看:57
本文介绍了如何在 ViewPager2 中以编程方式设置当前项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以在旧的ViewPager中,你可以使用

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

viewPager.setCurrentItem(x)

你如何在 ViewPager2 中做到这一点?

How do you do that in ViewPager2?

推荐答案

setCurrentItem 也是 ViewPager2 上的 API,所以你应该使用它.

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

这篇关于如何在 ViewPager2 中以编程方式设置当前项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆