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);
        } 
    } 
} 
6
CodeRank
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);
	} 
	 
6
CodeRank
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());
		} 
 
5
CodeRank
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));
5
CodeRank
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();
6
CodeRank
This code example shows how to use the following methods:setHasOptionsMenu
    public static final String ARG_ITEM_ID = "item_id";
 
    Article displayedArticle;
    DbAdapter db;
 
    public ArticleDetailFragment() { 
    	setHasOptionsMenu(true);	//this enables us to set actionbar from fragment
    } 
 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        db = new DbAdapter(getActivity());
        if (getArguments().containsKey(Article.KEY)) {
            displayedArticle = (Article) getArguments().getSerializable(Article.KEY);
        } 
    } 
 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
5
CodeRank
This code example shows how to use the following methods:getArguments, onCreate, setHasOptionsMenu
 
    private NotifyingAsyncQueryHandler mHandler;
 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        final Intent intent = BaseActivity.fragmentArgumentsToIntent(getArguments());
        mVendorUri = intent.getData();
        if (mVendorUri== null) {
            return; 
        } 
 
        setHasOptionsMenu(true);
    } 
 
    @Override 
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
 
5
CodeRank
This code example shows how to use the following methods:getArguments, onCreate, setHasOptionsMenu
 
    private NotifyingAsyncQueryHandler mHandler;
 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        final Intent intent = BaseActivity.fragmentArgumentsToIntent(getArguments());
        mVendorUri = intent.getData();
        if (mVendorUri== null) {
            return; 
        } 
 
        setHasOptionsMenu(true);
    } 
 
    @Override 
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
 
5
CodeRank
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) {
            menu.add("Menu 2")
                .setIcon(R.drawable.ic_title_share_default)
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getActivity, onCreate, setHasOptionsMenu
  @FragmentArg 
  public int id;
 
  @Override 
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
 
    setHasOptionsMenu(true);
 
    note = MoonRunes.notes.get(id);
 
    getActivity().setTitle(note.toString());
  } 
 
  @ViewById 
  public RuneView rune_view;
 
  @AfterViews 
  void loadNote() { 
    rune_view.note = note;
5
CodeRank

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: