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 8710229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:34:28+00:00 2026-06-13T04:34:28+00:00

I am a noob to android and i am trying to inflate two different

  • 0

I am a noob to android and i am trying to inflate two different menus depending on user selection. However, the menu isn’t switching. The same menu inflates everytime regardless of what the user selects. I’ve tried and checked my if/else statmente with various parameters and the menu inflater still doesn’t respond properly by only inflating the same menu. Any help is greatly appreciated.

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // TODO Auto-generated method stub
    super.onCreateOptionsMenu(menu);
    popUpMenu = getMenuInflater();
    //popUpMenu.inflate(R.menu.cool_menu, menu);
    if(mypodcast==null){
        popUpMenu.inflate(R.menu.cool_menu, menu);
    }else  {
        popUpMenu.inflate(R.menu.podcast, menu);
    }
    return true;
}
  • 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-13T04:34:29+00:00Added an answer on June 13, 2026 at 4:34 am

    The same menu inflates everytime regardless of what the user selects.

    That is because onCreateOptionsMenu() is not called each time you open the menu, from the documentation:

    This is only called once, the first time the options menu is displayed. To update the menu every time it is displayed, see onPrepareOptionsMenu(Menu)

    If you want to change menus you need to do this in onPrepareOptionsMenu(). However I don’t believe that you can or should inflate a new menu every time onPrepareOptionsMenu() is called. But you can combine the two menus and change the visibility of each menu item according to what you want in this method.

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

Sidebar

Related Questions

android noob... I have two tables, with a one to many relationship between country_tbl
This is an Android noob question. I am trying to start an activity of
I am a noob to android and I am trying to update a sqlite
I'm a noob to android and im am trying to query a sqlite table.
Im a noob to android and I am trying to run a query on
I'm a noob to Android, and I am trying to figure out how to
I am a noob to android trying to learn how to properly implement a
I'm a noob to android and i am trying to switch 4 views in
I am a noob to android development and i am trying to display rss
I'm a noob to android develop and i am trying to show a listview

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.