Discussion:
onCreateOptionsMenu not called
Teo
2008-09-25 09:02:30 UTC
Permalink
Hi,

onCreateOptionsMenu for my app isn't called anymore. I tried with SDK
1.0 just yesterday and it worked; today (still on SDK 1.0) the
function isn't called anymore and nothing happens when i hit Menu.

What might be the problem?

Thanks in advance,
Teo
Teo
2008-09-25 10:26:41 UTC
Permalink
Hi, here is my code

private boolean populateMenu(Menu menu) {
boolean result = super.onCreateOptionsMenu(menu);
MenuItem item1 = menu
.add(0, TAG_INSERT_ID, 0, R.string.menu_create);
item1.setAlphabeticShortcut('o');
item1.setIcon(R.drawable.add);
item1 = menu.add(0, TAG_REMOVE_ID, 0, R.string.menu_delete);
item1.setAlphabeticShortcut('i');
item1.setIcon(R.drawable.delete);
item1 = menu.add(0, TAG_EDIT_ID, 0, R.string.menu_edit);
item1.setAlphabeticShortcut('p');
item1.setIcon(R.drawable.rename);
item1 = menu.add(0, TAG_HELP_ID, 0, R.string.menu_rename);
item1.setAlphabeticShortcut('/');
item1.setIcon(R.drawable.help);
return result;
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
populateMenu(menu);
return true;
//return populateMenu(menu);
}

I've tried various combinations of this and couldn't find out what changed.

Thanks,
Teo
This has not been removed or changed AFAIK and it continues to work for me.What
exactly are you doing?
Post by Teo
Hi,
onCreateOptionsMenu for my app isn't called anymore. I tried with SDK
1.0 just yesterday and it worked; today (still on SDK 1.0) the
function isn't called anymore and nothing happens when i hit Menu.
What might be the problem?
Thanks in advance,
Teo
--
Teo (a.k.a. Teodor Filimon, Teominator)
Site - www.teodorfilimon.com | Blog - www.teodorfilimon.blogspot.com
GMT +2 (or PDT +10)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers-***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---
Mark Murphy
2008-09-25 14:50:28 UTC
Permalink
Post by Teo
Hi, here is my code
private boolean populateMenu(Menu menu) {
boolean result = super.onCreateOptionsMenu(menu);
Why are you calling super.onCreateOptionsMenu() from populateMenu()?
Post by Teo
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
populateMenu(menu);
Why are you calling super.onCreateOptionsMenu() twice, once here, and
once in populateMenu()?

I don't know if these are the source of your problem.
--
Mark Murphy (a Commons Guy)
http://commonsware.com
Warescription: All titles, revisions, & ebook formats, just $35/year
Teo
2008-09-25 16:53:22 UTC
Permalink
Thanks for pointing that out, it was an oversight. But it still didn't solve
the problem.onCreateOptionsMenu isn't even called :/
Post by Mark Murphy
Post by Teo
Hi, here is my code
private boolean populateMenu(Menu menu) {
boolean result = super.onCreateOptionsMenu(menu);
Why are you calling super.onCreateOptionsMenu() from populateMenu()?
Post by Teo
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
populateMenu(menu);
Why are you calling super.onCreateOptionsMenu() twice, once here, and
once in populateMenu()?
I don't know if these are the source of your problem.
--
Mark Murphy (a Commons Guy)
http://commonsware.com
Warescription: All titles, revisions, & ebook formats, just $35/year
--
Teo (a.k.a. Teodor Filimon, Teominator)
Site - www.teodorfilimon.com | Blog - www.teodorfilimon.blogspot.com
GMT +2 (or PDT +10)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers-***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---
Mark Murphy
2008-09-25 16:57:48 UTC
Permalink
Post by Teo
Thanks for pointing that out, it was an oversight. But it still didn't
solve the problem.onCreateOptionsMenu isn't even called :/
I was in a bit of a rush with the last reply and figured it would be worth
a shot.

Is onPrepareOptionsMenu() being called? That should be called on every
menu button press; onCreateOptionsMenu() will only get called on the first
menu button press.

--
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 1.2 Published!
Teo
2008-09-25 17:19:17 UTC
Permalink
Nope, nothing happens on prepare either. This is too strange, i remember the
other day i tried the menu and it worked in the latest SDK. Today with no
change in code, nothing, not even a call. I should say the menu works in
other apps, so the problem seems to be only with mine.
Post by Mark Murphy
Post by Teo
Thanks for pointing that out, it was an oversight. But it still didn't
solve the problem.onCreateOptionsMenu isn't even called :/
I was in a bit of a rush with the last reply and figured it would be worth
a shot.
Is onPrepareOptionsMenu() being called? That should be called on every
menu button press; onCreateOptionsMenu() will only get called on the first
menu button press.
--
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 1.2 Published!
--
Teo (a.k.a. Teodor Filimon, Teominator)
Site - www.teodorfilimon.com | Blog - www.teodorfilimon.blogspot.com
GMT +2 (or PDT +10)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers-***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---
Teo
2008-09-25 17:30:37 UTC
Permalink
I've replaced some PNG images i used for the menu, that's the closest thing
i did; but there shouldn't be any influence from that either..
Post by Teo
Nope, nothing happens on prepare either. This is too strange, i remember
the other day i tried the menu and it worked in the latest SDK. Today with
no change in code, nothing, not even a call. I should say the menu works in
other apps, so the problem seems to be only with mine.
Post by Mark Murphy
Post by Teo
Thanks for pointing that out, it was an oversight. But it still didn't
solve the problem.onCreateOptionsMenu isn't even called :/
I was in a bit of a rush with the last reply and figured it would be worth
a shot.
Is onPrepareOptionsMenu() being called? That should be called on every
menu button press; onCreateOptionsMenu() will only get called on the first
menu button press.
--
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 1.2 Published!
--
Teo (a.k.a. Teodor Filimon, Teominator)
Site - www.teodorfilimon.com | Blog - www.teodorfilimon.blogspot.com
GMT +2 (or PDT +10)
--
Teo (a.k.a. Teodor Filimon, Teominator)
Site - www.teodorfilimon.com | Blog - www.teodorfilimon.blogspot.com
GMT +2 (or PDT +10)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers-***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---
Teo
2008-09-26 19:33:46 UTC
Permalink
I just tried with the same project on another computer where i installed SDK
1.0 clean, same behavior...
Post by Teo
I've replaced some PNG images i used for the menu, that's the closest thing
i did; but there shouldn't be any influence from that either..
Post by Teo
Nope, nothing happens on prepare either. This is too strange, i remember
the other day i tried the menu and it worked in the latest SDK. Today with
no change in code, nothing, not even a call. I should say the menu works in
other apps, so the problem seems to be only with mine.
Post by Mark Murphy
Post by Teo
Thanks for pointing that out, it was an oversight. But it still didn't
solve the problem.onCreateOptionsMenu isn't even called :/
I was in a bit of a rush with the last reply and figured it would be worth
a shot.
Is onPrepareOptionsMenu() being called? That should be called on every
menu button press; onCreateOptionsMenu() will only get called on the first
menu button press.
--
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 1.2 Published!
--
Teo (a.k.a. Teodor Filimon, Teominator)
Site - www.teodorfilimon.com | Blog - www.teodorfilimon.blogspot.com
GMT +2 (or PDT +10)
--
Teo (a.k.a. Teodor Filimon, Teominator)
Site - www.teodorfilimon.com | Blog - www.teodorfilimon.blogspot.com
GMT +2 (or PDT +10)
--
Teo (a.k.a. Teodor Filimon, Teominator)
Site - www.teodorfilimon.com | Blog - www.teodorfilimon.blogspot.com
GMT +2 (or PDT +10)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers-***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---
Ludwig
2008-09-25 10:22:23 UTC
Permalink
This has not been removed or changed AFAIK and it continues to work for me.What
exactly are you doing?
Post by Teo
Hi,
onCreateOptionsMenu for my app isn't called anymore. I tried with SDK
1.0 just yesterday and it worked; today (still on SDK 1.0) the
function isn't called anymore and nothing happens when i hit Menu.
What might be the problem?
Thanks in advance,
Teo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers-***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---
Loading...