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