private void scrollToItem(int item, boolean smoothScroll, int velocity) { final ItemInfo curInfo = infoForPosition(item); int destX = 0; if (curInfo != null) { destX = (int) (getClientWidth() * Math.max(firstOffset, Math.min(curInfo.offset, lastOffset))); } if (smoothScroll) { smoothScrollTo(destX, 0, velocity); } else { completeScroll(false); scrollTo(destX, 0); pageScrolled(destX); } }