Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8177495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:31:31+00:00 2026-06-06T23:31:31+00:00

I have 3 Fragment s which, in a normal (small) layout are all in

  • 0

I have 3 Fragments which, in a normal (small) layout are all in separate Activities. They should provide an optionsmenu in the small layout.

In the large layout, I have the 3 fragments in one Activity, causing the menu to fill with the buttons inflated by all three fragments. How can I prevent this, and only let the Activity inflate the optionsmenu, while still holding the functionality on smaller devices?

-Edit-

So each Fragment uses the following code:

@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    /* Some code */
    setHasOptionsMenu(true);
    /* Some code */
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
    inflater.inflate(R.menu.mymenu, menu);
}

When all three Fragments are shown, all Fragments execute onCreateOptionsMenu() and all items appear three times.
What I want is for the parent Activity to take the responsibility of creating the options menu.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:31:32+00:00Added an answer on June 6, 2026 at 11:31 pm

    In each Fragment I would build the entire menu. What I’ve done is, to add in the Fragments only their specific menu items, and in the parent Activity I would build the general items.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fragment interface with tabs along the bottom which open different fragments
I have page which consists of couple fragments and in the header fragment I
I have an app using fragments, all of which are contained in a single
I have a ViewPager within a Fragment which contains three Fragments we'll call V1,
I have a HTML fragment which contains two anchor tags in various parts of
I have a fragment of html which is contained in a property of a
Lets say you have a fragment of the page which displays the most recent
I have an Activity which uses a Fragment . I simply want to pass
I have a xsl:variable ($features-list) specified in my XSL which contains a tree fragment
I have the following . I have a fragment on the left which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.