Code example for FragmentPagerAdapter

Methods: instantiateItem

0
 
    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);
    	} 
    } 
 
	@Override 
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    } 
 
    @Override 
    public void onPageSelected(int position) {