Menus across subactivities

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Menus across subactivities

Postby Erykgecko » Sat Aug 01, 2009 3:26 pm

Hi,

I have an app which works fine, and on the main activity I can call up the menu by pressing the mnu button on my phone and thats fine, and within that, i cn click on an option that will start a subactivity, this is also fine.

Now however I want to add a new menu with different options to the subactivity, Surely this should be a simple case of adding the onCreateOptionsMenu(Menu menu) to the subactivity code. but for some reason it just wont work. When I click the menu button nothing appears.

is there any sort of restriction on menu creationwithin subactivities? and if so is there any work around?

Thanks
Erykgecko
Junior Developer
Junior Developer
 
Posts: 20
Joined: Sat May 16, 2009 5:32 pm

Top

Postby TheChosen » Mon Aug 03, 2009 11:15 am

A sub activity is nothing else than a normal activity which calls finish() at some point. So the onCreateOptionsMenu() callback method should work without any problems. Have you searched your code for typos?
TheChosen
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Tue Jan 06, 2009 7:18 pm
Location: Germany

Postby Erykgecko » Sun Aug 09, 2009 12:58 am

ah yeah,

I fixed this and forgot to post what my error was.

Basically, I had an onKeyDown() event, and for some reason it was not recognising anything other than the button i was monitoring, though i was told that super.onKeyDown(keyCode, event); would keep the default key presses working, for some reason it wasn't

I simply added a check for when the menu key was pressed, and then called the menu function.
Erykgecko
Junior Developer
Junior Developer
 
Posts: 20
Joined: Sat May 16, 2009 5:32 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests