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) {

}
});
posted @ 2017-08-16 17:03  wzjhoutai  阅读(230)  评论(0编辑  收藏  举报