private View viewForPage(int page) { // if the requested page is outside of the adapters scope, return null. // This should only happen when over flipping with mode RUBBER_BAND if (page < 0 || page >= mPageCount) { return null; } final int viewType = mAdapter.getItemViewType(page); // check if view needed is in active views, if so order to front and // return this view View v = getActiveView(page); if (v != null) { return v; } // get(and remove) a convertview with correct viewtype from recycled // views v = mRecycler.getScrapView(page, viewType); // pass that view (can be null) into adapter to fill the view v = mAdapter.getView(page, v, this); // insert that view into active views pushing the least used active view // into recycled views addToActiveView(v, page, viewType); // measure and layout view measureAndLayoutChild(v); // return view return v; }