Link to home
Start Free TrialLog in
Avatar of jagguy
jagguyFlag for Australia

asked on

menu example

I am having trouble finding menu examples that work.
I copied the code and download menu examples without success.

I am after complete menu examples to learn about menus.
Avatar of jagguy
jagguy
Flag of Australia image

ASKER

I got one to work .

when does this code run because there is no call to this. Is it when you hit menu on the emulator?
 
@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu, menu);
        return true;
    }
http://developer.android.com/guide/topics/ui/menus.html

To specify the options menu for an activity, override onCreateOptionsMenu() (fragments provide their own onCreateOptionsMenu() callback). In this method, you can inflate your menu resource (defined in XML) into the Menu provided in the callback. For example:
(here exactly the same code as yours quoted above)

If you've developed your application for Android 2.3.x and lower, the system calls onCreateOptionsMenu() to create the options menu when the user opens the menu for the first time. If you've developed for Android 3.0 and higher, the system calls onCreateOptionsMenu() when starting the activity, in order to show items to the action bar.
ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jagguy

ASKER

Thanks for the information.
Yes, AdapterView.OnItemCLickListener - it locates and imports both these types for me based on that code which you pointed to