The code is very simple, to mlistview monitoring Onscrolllistener events, and then in onscroll to judge
The index of the first item in the ListView Private int mlistviewfirstitem = 0;//listview the position of the first item in the screen Private int mscreeny = 0;//whether to scroll up private boolean misscrolltoup = false; @Overridepublic void onscroll (abslistview abslistview, int firstvisibleitem,int Visibleitemcount, int totalitemcount) {if (Mlistview.getchildcount () >0) {boolean isscrolltoup = false; View childat = mlistview.getchildat (Firstvisibleitem);int[] location = new Int[2];childat.getlocationonscreen (location); LOG.D ("onscroll", "firstvisibleitem= " +firstvisibleitem+ " , y=" +location[1]); if ( Firstvisibleitem!=mlistviewfirstitem) {if (Firstvisibleitem>mlistviewfirstitem) {LOG.E ("--->", "swipe up") ; isscrolltoup = true;} ELSE{LOG.E ("--->", "swipe Down"); isscrolltoup = false;} MLISTVIEWFIRSTITEM&NBSP;=&NBSP;FIRSTVISIBLEITEM;MSCREENY&NBSP;=&NBSP;LOCATION[1];} Else{iF (mscreeny>location[1]) {LOG.I ("--->", "); isscrolltoup = true;} Else if (Mscreeny<location[1]) {LOG.I ("--->", ", Slide Down"); isscrolltoup = false;} MSCREENY&NBSP;=&NBSP;LOCATION[1];} if (misscrolltoup!=isscrolltoup) {onscrolldirectionchanged (Misscrolltoup);}}} Private void onscrolldirectionchanged (Boolean isscrolltoup) {}
Android to determine the slide direction of the ListView