Code example for FragmentPagerAdapter

Methods: instantiateItem

    public Fragment getCachedItem(int position) {
        // Do we already have this fragment? 
    	if (!mSingletonMap.containsKey(position)) {
    		Log.i(getClass().getName(), "Fragment cache miss");
	        Fragment fragment = (Fragment) instantiateItem(mViewPager, position);
	        mSingletonMap.put(position, fragment);
	        return fragment;
    	} else { 
    		Log.i(getClass().getName(), "Fragment cache hit");
    		return mSingletonMap.get(position);
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    public void onPageSelected(int position) {
Stop searching for code, let great code find you!  Add Codota to your java IDE