Code example for AbsListView

Methods: getCount, getFirstVisiblePosition, getLastVisiblePosition

0
 
		if(listView == null)
			Assert.assertTrue("No ListView with index " + listIndex + " is found!", false);
 
		if (direction == DOWN) {
			if (listView.getLastVisiblePosition() >= listView.getCount()-1) {
				scrollListToLine(listView, listView.getLastVisiblePosition());
				return false; 
			} 
			 
			if(listView.getFirstVisiblePosition() != listView.getLastVisiblePosition())
				scrollListToLine(listView, listView.getLastVisiblePosition());
	 
			else 
				scrollListToLine(listView, listView.getFirstVisiblePosition()+1);
 
		} else if (direction == UP) {
			if (listView.getFirstVisiblePosition() < 2) {
				scrollListToLine(listView, 0);
				return false; 
			} 
 
			final int lines = listView.getLastVisiblePosition() - listView.getFirstVisiblePosition();
			int lineToScrollTo = listView.getFirstVisiblePosition() - lines;
 
			if(lineToScrollTo == listView.getLastVisiblePosition())
				lineToScrollTo--;
			 
			if(lineToScrollTo < 0)
				lineToScrollTo = 0;