Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

menu example

Posted on 2012-03-27
5
Medium Priority
?
310 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
[X]
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
  • 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Here, we have shared an easy step by step tutorial on how to download instagram images and videos on PC, Android Mobile and iOS mobile.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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.
Suggested Courses

715 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