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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:41:54+00:00 2026-06-03T23:41:54+00:00

I am going through a tutorial, and it showed this example code to make

  • 0

I am going through a tutorial, and it showed this example code to make a menu:

public void onCreateOptionsMenu(Menu m) {
        super.onCreateOptionsMenu(m);
        MenuInflater menuInflater = getMenuInflater();
        menuInflater.inflate(R.menu.time_list_menu, m);
    }

I got an error and so I changed it to boolean, which is what it is now, and so I did this instead, and its working:

public boolean onCreateOptionsMenu(Menu m) {
      super.onCreateOptionsMenu(m);
      MenuInflater menuInflater = getMenuInflater();
      menuInflater.inflate(R.menu.time_list_menu, m);
      return true;
  }

But I also have stuff like this from another question here on stack overflow

Understanding why onCreateOptionsMenu is not displaying a menu

The Android doc also has this:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.game_menu, menu);
    return true;
  }

Where did the call to super go and why is it not necessary? What is the correct way to make a menu if I am doing it wrong?

While I am on the subject, the Doc also shows @Override, but I don’t have it, and its working. I am just confused as to whether that is necessary if the methods are explicitly being overridden. I appreciate the help. IF any clarification is needed, please let me know.

  • 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-03T23:41:55+00:00Added an answer on June 3, 2026 at 11:41 pm

    To address your two specific problems:

    1. super.onCreateOptionsMenu: In general it is a good idea to call base class functions in this way when you intend to refine their actions. In this case it makes no difference (as far as you can tell) but the documentation recommends it so you should execute it to ensure future android version compatibility.
    2. @Override: this annotation is voluntary but is very useful, it ensure that the method signature matches that of the underlying base class. This means that if you declare the method slightly wrong (in the sense of different to the method that it is overriding) the compiler will pick up the discrepancy (as opposed to just considering it a new method and not calling it in the context)

    Thus both are useful and correct if not strictly needed.

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

Sidebar

Related Questions

I been going through this tutorial http://www.codeproject.com/KB/linq/BulkOperations_LinqToSQL.aspx and them make a SP like this
I was going through this tutorial http://www.schillmania.com/content/projects/javascript-animation-1/ and when I institute the code, I
I'm going through a Haskell tutorial and am given this piece of code to
I am going through this tutorial about PDO and have come to the point
I am going through a tutorial that mentions the following method: -(void)layoutSubviews located in
Trying to learn a bit about PDO and is going through this tutorial .
I'm going through this tutorial: http://tutorials.jumpstartlab.com/projects/jsattend.html In iteration 7, step 3 we get to
So I'm going through this tutorial that seems so simple but I can't seem
I was going through this tutorial in order to learn how Django works: https://docs.djangoproject.com/en/dev/intro/tutorial01/
I been going through this tutorial and it looks really good. So I went

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.