Fragment setHasOptionsMenu - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Fragment setHasOptionsMenu method.

This code example shows how to use the following methods: onCreate, setHasOptionsMenu
     */ 
    public static class Menu2Fragment extends Fragment {
 
        @Override 
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setHasOptionsMenu(true);
        } 
 
        @Override 
        public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
            MenuItem item;
            item = menu.add("Menu 2");
            MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
        } 
    } 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setHasOptionsMenu
	 
	public PlasmaSubFragment() { 
		//eek! I wish fragments weren't lame and required this. 
	} 
	 
	public PlasmaSubFragment(PDActivity p) {
		this.p = p;
		setHasOptionsMenu(true); 
	} 
	 
	public void setup() { 
		 
	} 
	 
	 
	@Override 
	public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
	    inflater.inflate(getMenu(), menu);
	} 
	 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: onCreate, setHasOptionsMenu
    } 
     
    public final class TestFragment extends Fragment {
		@Override 
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
    		setHasOptionsMenu(true);
		} 
 
		@Override 
		public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
			menu.add(0, 0, 0, MENU_ITEM_TEXT)
				.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
		} 
		 
		@Override 
		public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
			return new FrameLayout(getActivity());
		} 
 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getActivity, onCreate, setHasOptionsMenu
    private WebView mWebView;
    private View mLoadingSpinner;
 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setHasOptionsMenu(true);
        AnalyticsUtils.getInstance(getActivity()).trackPageView("/Map");
    } 
 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
 
        ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_webview_with_spinner, null);
 
        // For some reason, if we omit this, NoSaveStateFrameLayout thinks we are 
        // FILL_PARENT / WRAP_CONTENT, making the progress bar stick to the top of the activity. 
        root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT));
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: onActivityCreated, setHasOptionsMenu
public class PagerFragment extends Fragment implements PagerItem {
 
 
	@Override 
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		setHasOptionsMenu(true);
	} 
 
	@Override 
	public ActionList getActions() { 
		return null; 
	} 
 
	@Override 
	public void pageIsActive(CpuTunerViewpagerActivity cpuTunerViewpagerActivity) {
		if (!SettingsStorage.getInstance(getActivity()).hasHoloTheme()) {
			ActionList actions = getActions();
			if (actions != null) {
				ActionBarWrapper actionBarWrapper = cpuTunerViewpagerActivity.getActionBarWrapper();
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Fragment setHasOptionsMenu Questions & Answers:

setHasOptionsMenu Method Overview
Report that this fragment would like to participate in populating the options menu by receiving a call to onCreateOptionsMenu(Menu, MenuInflater) and related methods.
See Code Examples for other Android Fragment Methods: