setOnPageChangeListener 过时了怎么办?
今天使用
ViewPager
发现setOnPageChangeListener
的方法竟然过期了。并且AS编译不通过了,最后查了一下原来把set
换成add
了,代码例如以下:
setOnPageChangeListener
mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
addOnPageChangeListener
mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
selectedTab(position);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});