Code example for AbsListView

Methods: getCount, getFirstVisiblePosition, getLastVisiblePosition

0
			return false; 
		} 
 
		if (direction == DOWN) {
			if (allTheWay) {
				scrollListToLine(absListView, absListView.getCount()-1);
				return false; 
			} 
			if (absListView.getLastVisiblePosition() >= absListView.getCount()-1) {
				scrollListToLine(absListView, absListView.getLastVisiblePosition());
				return false; 
			} 
 
			if(absListView.getFirstVisiblePosition() != absListView.getLastVisiblePosition())
				scrollListToLine(absListView, absListView.getLastVisiblePosition());
 
			else 
				scrollListToLine(absListView, absListView.getFirstVisiblePosition()+1);
 
		} else if (direction == UP) {
			if (allTheWay || absListView.getFirstVisiblePosition() < 2) {
				scrollListToLine(absListView, 0);
				return false; 
			} 
 
			final int lines = absListView.getLastVisiblePosition() - absListView.getFirstVisiblePosition();
			int lineToScrollTo = absListView.getFirstVisiblePosition() - lines;
 
			if(lineToScrollTo == absListView.getLastVisiblePosition())
				lineToScrollTo--;
 
			if(lineToScrollTo < 0)
				lineToScrollTo = 0;