Code example for FragmentTransaction

Methods: attach

0
            // If not, instantiate and add it to the activity 
            mFragment = Fragment.instantiate(mActivity, mClass.getName());
            ft.add(android.R.id.content, mFragment, mTag);
        } else { 
            // If it exists, simply attach it in order to show it 
            ft.attach(mFragment);
        } 
	} 
 
	@Override 
	public void onTabUnselected(Tab tab, FragmentTransaction ft) {
		if (mFragment != null) {
            // Detach the fragment, because another one is being attached 
            ft.detach(mFragment);
        } 
	} 
}