Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Menu problem

 
Hardik Trivedi
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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."
 
Hardik Trivedi
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:


Not working..
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hm...

It is strange but if I write @Override there Eclipse give me error.
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if I write @Override there Eclipse give me error.


what error?
 
Hardik Trivedi
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It says remove ....
The method onCreateOptionMenu(Menu) of type SimpleOptionMenu must override or implement a supertype method
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiya.. Problem solved :-)

Thank you Ulf and Pramod
 
pradeep potnuru
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic