Android 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) { } });