能支持下 viewpage2?
lastzhou opened this issue · comments
点开 ViewPagerHelper 的代码你就知道该怎么做了
点开 ViewPagerHelper 的代码你就知道该怎么做了
binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
@OverRide
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
binding.mMagicIndicator.onPageScrolled(position, positionOffset, positionOffsetPixels);
}
@Override
public void onPageSelected(int position) {
binding.mMagicIndicator.onPageSelected(position);
}
@Override
public void onPageScrollStateChanged(int state) {
binding.mMagicIndicator.onPageScrollStateChanged(state);
}
});
很简单,调用viewPager.setCurrentItem(index,false)就可以