Viewpager.setonpagechangelistener (New Onpagechangelistener () { @Override public void onpageselected (int Select) { //TODO auto-generated method Stub Log. D ("DML", "Onpageselected:::::select ============" + Select); c4/>} @Override public void onpagescrolled (int positon, float arg1, int arg2) { //TODO auto-generated method Stub Log. D ("DML", "onpagescrolled:::::p osition =" + Positon); } @Override public void Onpagescrollstatechanged (int.) { //TODO auto-generated method Stub Log. D (" DML "," onpagescrollstatechanged:::::state = "+ state); } );
1.
position is always the index of the first interface from left to right in the current interface, regardless of whether you are sliding so that there is no sliding at first onpagescrolled will also be called once, and position= 0. Sliding is actually divided into two processes: first the finger drive Viewpager slide, then the finger left the screen Viewpager will handle (either rebound or swipe to the next interface), the whole process onpagescrolled will be callback, Of course, position will always change .
2. the onpagescrollstatechanged will be recalled three times in a single swipe, in order 1 > 2 > 0 where 2 is the finger left the screen, the sliding event is successful, onpageselected must be in this 2 step after the execution, and only the current interface changes only callback, assignment bit the current interface index, so rebound onpageselected it will not callback
3. To determine which way the user slides, it should be judged with two conditions: the current interface int index, sliding position. For example: currently in the second interface, then int index = 1, at this time position = 1, the user starts to slide to the first interface POS Ition immediately becomes 0(because the first interface has been leaked) if you are sliding toward the third interface, position will remain at 1 (because the second interface is not completely hidden) until the third interface is completely sliding position=2 good, Now continue to the left slide because has been to the right of the row is not moving so position at this time has been maintained 2, the same in the first interface right sliding position will remain as 0
Parameter interpretation of Viewpager sliding monitoring