好的,这基本上是我想要完成的事情:我有一个 FragmentStatePagerAdapter 并且希望偶尔禁用滑动功能并使用按钮前进/后退。
从我在 MyFragmentStatePagerAdapter 中的代码中截取的 A 扩展了 FragmentStatePagerAdapter :(适用于滑动,仅用于您的定位)
public Fragment getItem(int position) {
Item item = items.get(position/2);
if (position%2 == 0) return new MyFragmentA(item, param1);
if (position%2 == 1) return new MyFragmentB(item, param1);
return null;
}
有什么建议么?我只需要停用滑动并使用 2 个按钮...
谢谢