mPager.setOnPageChangeListener(new OnPageChangeListener()
{
@Override
public void onPageSelected(int arg0) {
// TODO Auto-generated method stub
for (int i = 0; i < mDotsLayout.getChildCount(); i++) {
if(i == arg0){
mDotsLayout.getChildAt(i).setSelected(true);
} else {
mDotsLayout.getChildAt(i).setSelected(false);
}
}
if(arg0 == mDotsLayout.getChildCount()-1){//立即进入按钮是否展示
mBtn.setVisibility(View.VISIBLE);
} else {
mBtn.setVisibility(View.GONE);
}
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
// TODO Auto-generated method stub
if(isScroll&&(arg0 == viewList.size()-1)){//页面跳转
Intent intent = new Intent(getApplicationContext(),HomeActivity.class);
startActivity(intent);
finish();
}
}
@Override
public void onPageScrollStateChanged(int arg0) {
// TODO Auto-generated method stub
boolean flag = false;
switch (arg0) {
case ViewPager.SCROLL_STATE_DRAGGING:
flag= false;
break;
case ViewPager.SCROLL_STATE_SETTLING:
flag = true;
break;
case ViewPager.SCROLL_STATE_IDLE:
if (mPager.getCurrentItem() == mPager.getAdapter().getCount() - 1 && !flag) {
isScroll = true;
}else{
isScroll = false;
}
flag = true;
break;
}
}
});
网站标题:viewPaper判断是否是最后一页继续滑动的操作
本文网址:
http://cdxtjz.cn/article/ijdjhh.html