Code example for FragmentActivity

Methods: getMenuInflater, onCreateOptionsMenu

1
		return super.getMenuInflater(); 
	} 
 
	@Override 
	public MenuInflater getMenuInflater() {
		return mActionBarCompat.getMenuInflater(super.getMenuInflater());
	} 
 
	public ActionBar getSupportActionBar() {
		return mActionBarCompat.getActionBar();
	} 
 
	public void invalidateSupportOptionsMenu() { 
		if (mActionBarCompat instanceof ActionBarCompatNative) {
			MethodsCompat.invalidateOptionsMenu(this);
		} else if (mActionBarCompat instanceof ActionBarCompatBase) {
			((ActionBarCompatBase) mActionBarCompat).invalidateOptionsMenu();
		} 
	} 
 
	@Override 
	public void onAttachFragment(final Fragment fragment) {
		super.onAttachFragment(fragment);
		mAttachedFragment = fragment;
		if (mActionBarCompat instanceof ActionBarCompatBase) {
			((ActionBarCompatBase) mActionBarCompat).createActionBarMenu();
		} 
	} 
 
	@Override 
	public void onBackPressed() { 
		if (mActionBarCompat instanceof ActionBarCompatBase) {
			if (((ActionBarCompatBase) mActionBarCompat).isActionModeShowing() && mActionModeCompat != null) {
				mActionModeCompat.finish();
			} 
		} 
		super.onBackPressed(); 
	} 
 
	@Override 
	public void onContentChanged() { 
		super.onContentChanged(); 
		initActionBar(); 
		checkActionBar(); 
		if (mActionBarCompat.isAvailable()) {
			switch (mWindowFeatureId) {
				case Window.FEATURE_INDETERMINATE_PROGRESS: {
					if (mActionBarCompat instanceof ActionBarCompatBase) {
						((ActionBarCompatBase) mActionBarCompat).setProgressBarIndeterminateEnabled(true);
					} 
				} 
			} 
		} 
	} 
 
	@Override 
	public boolean onCreateOptionsMenu(final Menu menu) {
		if (mActionBarCompat instanceof ActionBarCompatBase) {
			if (((ActionBarCompatBase) mActionBarCompat).isActionModeShowing()) return false;
		} 
		boolean retValue = super.onCreateOptionsMenu(menu);
		if (mActionBarCompat instanceof ActionBarCompatBase) {
			if (mAttachedFragment != null) {
				mAttachedFragment.onCreateOptionsMenu(menu, getMenuInflater());
			} 
			retValue = true;