use of com.example.jingbin.cloudreader.view.OnMyPageChangeListener in project CloudReader by youlookwhat.
the class MainActivity method initContentFragment.
private void initContentFragment() {
// 注意使用的是:getSupportFragmentManager
CommonTabPagerAdapter adapter = new CommonTabPagerAdapter(getSupportFragmentManager(), Arrays.asList("", "", ""));
adapter.setListener(this);
vpContent.setAdapter(adapter);
// 设置ViewPager最大缓存的页面个数(cpu消耗少)
vpContent.setOffscreenPageLimit(2);
vpContent.addOnPageChangeListener(new OnMyPageChangeListener() {
@Override
public void onPageSelected(int position) {
switch(position) {
case 0:
setCurrentItem(0);
break;
case 1:
setCurrentItem(1);
break;
case 2:
setCurrentItem(2);
break;
default:
break;
}
}
});
setCurrentItem(0);
}
Aggregations