android - ViewPager swipe issue when back press -
here trying move next screen @ view pager last position..and moving .but when try swipe last position ,it moves next screen.i need move next screeen when view pager @ last position.
@override public void onpagescrollstatechanged(int state) { //viewpager swipe lastpagechange = false; int lastidx = viewpager.getadapter().getcount() - 1; curitem = viewpager.getcurrentitem(); if (curitem==lastidx && state==1 && lastpagechange==false ) { lastpagechange = true; intent main=new intent(top3.this,skipactivity.class); startactivity(main); finish(); } else { lastpagechange = false; } }
this answer viewpager when seen last position swipe again forward go next activity. viewpager.onpagechangelistener pagerlistener = new viewpager.onpagechangelistener() { boolean lastpagechange = false;
@override public void onpagescrolled(int position, float positionoffset, int positionoffsetpixels) { int lastidx = book_adapt.getcount() - 1; log.d("testing", "pos:" + position); if (lastpagechange && position == lastidx){ intent main = new intent(top3.this, skipactivity.class); startactivity(main); finish(); } } @override public void onpageselected(int position) { // pgtext.setcurrentitem(i/2); viewpagerset(position); } @override public void onpagescrollstatechanged(int state) { int lastidx = book_adapt.getcount() - 1; int curitem = viewpager.getcurrentitem(); if (curitem == lastidx /*&& lastpos==lastidx*/ && state == 1) lastpagechange = true; else lastpagechange = false; } }; viewpager.addonpagechangelistener(pagerlistener);
Comments
Post a Comment