aspose file tools*
The moose likes Android and the fly likes Menu problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Menu problem" Watch "Menu problem" New topic
Author

Menu problem

Hardik Trivedi
Ranch Hand

Joined: Jan 30, 2010
Posts: 252
Hi,

I am very much new to Android and follow tutorial blindly.
I am trying to create menus and I am having trouble in creating them.
Following is the code which I have done..


I am not able to see the menus.What I can see is only application name and welcome message.
I pushed MENU button also but still problem is there.

Please take me out of this..
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42644
    
  65
The first line of the onCreateOptionMenu method should always be

super.onCreateOptionsMenu(menu);

That's what the javadocs mean by "Deriving classes should always call through to the base implementation."


Ping & DNS - my free Android networking tools app
Hardik Trivedi
Ranch Hand

Joined: Jan 30, 2010
Posts: 252
Ulf Dittmer wrote:
super.onCreateOptionsMenu(menu);


Hi Ulf,
Thank you for the answer.I did that but still I am not able to see the menu item.
Actually onCreateOptionMenu method is not being called.


Any other way ???
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42644
    
  65
Be sure to attach an @Override annotation to any method that you think is overriding some other method; that'll catch any typos you made.
Hardik Trivedi
Ranch Hand

Joined: Jan 30, 2010
Posts: 252
Ulf Dittmer wrote:


Not working..
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42644
    
  65
Please read ItDoesntWorkIsUseless. You don't even tell us what isn't working, much less how it's not working. How are we supposed to help you?
Hardik Trivedi
Ranch Hand

Joined: Jan 30, 2010
Posts: 252
Hi, First of all thank you very much for taking bother for me.You guys are doing excellent job.
But I have posted entire class.What else you expect from my side.
Should I post all xml files also?I did not do that because this forum is not a code factory.

Moreover I am new to Android and as i told that I follow the tutorials blindly.

In some tutorials it is written that menu will be displayed when you push the menu button.I did that also.
Is problem is on SDK side?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42644
    
  65
Please refrain from using color tags for entire posts; those are meant for highlighting short sections of particular interest.

You're right that you should not post all the XML files. I suggested that using @Override annotations could help you find the problem. To that you replied "not working", which I take to mean that you did change something. But you didn't tell us what you changed, nor did you post the newly changed code. It would not be a good use of our time to try and guess what you changed and give you advice based on that.

So: What did you change?
Hardik Trivedi
Ranch Hand

Joined: Jan 30, 2010
Posts: 252


Above are the very few changes that I have done.
All XML files are correct.
onCreateOptionMenu(Menu menu) method is not being called

And if you have correct code please give it to me.I have spent two days working on this much small piece of code.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42644
    
  65
If "onCreateOptionMenu(Menu menu)" is not getting called, then that's where you should focus your attention - and it's the one method that does not have an @Override annotation.

And if you have correct code please give it to me.

No. You'll learn much better if you figure stuff out on your own. Developing is all about paying attention to details, and that's where I'm trying to guide you.
Hardik Trivedi
Ranch Hand

Joined: Jan 30, 2010
Posts: 252
hm...

It is strange but if I write @Override there Eclipse give me error.
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

if I write @Override there Eclipse give me error.


what error?


Life is easy because we write the source code.....
Hardik Trivedi
Ranch Hand

Joined: Jan 30, 2010
Posts: 252
It says remove ....
The method onCreateOptionMenu(Menu) of type SimpleOptionMenu must override or implement a supertype method
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42644
    
  65
So the method you have does NOT override any other method - that explains why it is not called. Now: WHY does it not override the method that you think it overrides? Again, pay attention to detail.
Hardik Trivedi
Ranch Hand

Joined: Jan 30, 2010
Posts: 252
Hiya.. Problem solved :-)

Thank you Ulf and Pramod
pradeep potnuru
Greenhorn

Joined: Apr 24, 2012
Posts: 1
Hi
Can you please post me in detail how the problem was solved!!!
I am also facing the same problem what you faced.

Thanks in advance.
 
Don't get me started about those stupid light bulbs.
 
subject: Menu problem