Code example for FragmentTransaction

Methods: commit, replace

0
		fragment = getFragment(fragmentRecycle);
		FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
		if (fragmentRecycle == null) {
			transaction.add(R.id.root_container, fragment);
		} else if ((fragment != null) && !fragmentRecycle.equals(fragment)) {
			transaction.replace(R.id.root_container, fragment);
		} 
		transaction.commit();
 
	} 
 
	@Override 
	protected int getLayout() { 
		return R.layout.empty; 
	} 
 
	protected abstract T getFragment(Fragment fragmentRecycle);
 
}