Solved

menu example

Posted on 2012-03-27
5
302 Views
Last Modified: 2012-03-27
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.
0
Comment
Question by:jagguy
  • 3
  • 2
5 Comments
 

Author Comment

by:jagguy
ID: 37770878
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;
    }
0
 
LVL 47

Expert Comment

by:for_yan
ID: 37773127
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.
0
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 37773225
>when does this code run because there is no call to this.
All these are callback functions - you prepare the contents of those but you'll not see any calls to them in your code - they are called by the "container" (in this case it would be Android opertaing system I giess), which knows that at some apparopriate moment of the life cycle of applaication or part of it cvertain method needs to be called.
0
 

Author Comment

by:jagguy
ID: 37774330
Thanks for the information.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 37774374
Yes, AdapterView.OnItemCLickListener - it locates and imports both these types for me based on that code which you pointed to
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
If your app took Google’s lash recently, here are the 5 most likely reasons.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now