addOnPageChangeListener is deprecated or addOnPageChangeListener not working or how to use addOnPageChangeListener in viewpager 2 in android.
The problem describe below:-
viewpager setonpagechangelistener deprecated or viewPager.setOnPageChangeListener not working [duplicate] or setOnPageChangeListener is deprecated now or How to useaddOnPageChangeListenermethodinandroidx.viewpager.widget.ViewPager Aandroid - viewpager setonpagechangelistener deprecated.
This is deprecated.
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
invalidateFragmentMenus(position);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
invalidateFragmentMenus(viewPager.getCurrentItem());
}
This is new which you will have to use in viewPager 2.
viewPager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
}
});
Comments
Post a Comment