Code example for FragmentTransaction

Methods: commit, detach

0
			// initial state is that a tab isn't shown. 
			FragmentManager fm = mActivity.getSupportFragmentManager();
			mFragment = fm.findFragmentByTag(mTag);
			if (mFragment != null && !mFragment.isDetached()) {
				FragmentTransaction ft = fm.beginTransaction();
				ft.detach(mFragment);
				ft.commit();
			} 
		} 
 
		@Override public void onTabSelected(Tab tab, FragmentTransaction ft) {
			if (mFragment == null) {
				mFragment = Fragment.instantiate(mActivity, mClass.getName(), mArgs);
				ft.add(android.R.id.content, mFragment, mTag);
			} else { 
				ft.attach(mFragment);
			} 
			 
			if (mFragment instanceof GotoDirectFragment) {
				((GotoDirectFragment) mFragment).onTabSelected();
			} else {