Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

menu example

Posted on 2012-03-27
5
305 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
runtime exception 2 41
by zero exception 10 52
Details to create developer account 10 50
restrict decimal places for double datatype 10 19
This is an explanation of a simple data model to help parse a JSON feed
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
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.

808 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