Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Android and the fly likes optionmenu not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "optionmenu not working" Watch "optionmenu not working" New topic
Author

optionmenu not working

sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1117
this is my java class




this is my menu.xml file(res/menu/menu.xml)

<?xml version="1.0" encoding="UTF-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/opt1"
android:title="Option 1" />
<item android:id="@+id/opt2"
android:title="Option 2" />
<item android:id="@+id/opt3"
android:title="Option 3" />
<item android:id="@+id/opt4"
android:title="Option 4" />
<item android:id="@+id/opt5"
android:title="Option 5" />
</menu>


this is my main.xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
androidrientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>



but when run the project it doesn't show the menu.please see thebelow URL.

webpage


[Thumbnail for Menu.gif]

Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

What happens when you press the Menu button on the emulator?


Steve
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1117
thanks,it gives the result.

http://i693.photobucket.com/albums/vv299/asliyanage/Menu2.gif?t=1366283192
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41823
    
  63
So what, exactly, do you mean by "run the project"? Running the app doesn't cause the options menu to be displayed. Pressing the Menu button does, as Steve pointed out.

By the way, please attach images right here to the post, not at some 3rd party site - makes it much to check out the image, and sometimes those external sites are blocked, making it impossible to see the images.


Ping & DNS - my free Android networking tools app
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1117
I use third party site as i try to attached files directly it gives me error.anyway how can i enable to load optionmenu without clicking Menu button.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41823
    
  63
Why would you want to do that? People are used to using the Menu button; it's there for invoking the options menu, after all. I'd say you need very good reasons for altering the behavior of an app so that it deviates from the Android standard.
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1117
it's better to use button,if i need to see them without clicking Menu button.is it correct?
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

sameera liyanage wrote:it's better to use button,if i need to see them without clicking Menu button.is it correct?

Yes, you have to decide when and where those actions will be used. If the actions are part-and-parcel to how the activity works - i.e. they will always be pressed - then you should use normal Buttons to trigger those actions, and those buttons should be part of the normal UI. If the actions are optional or rarely used / one-off actions in normal situations then you should put them in a Menu, so they don't take up UI space and are accessible to the user when they need them.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41823
    
  63
sameera liyanage wrote:it's better to use button,if i need to see them without clicking Menu button.is it correct?

I'm a bit confused where you see the difference between Android's menu button, and some button that is part of your app. You need to click one or the other no matter what ... ?
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1117
I'm a bit confused where you see the difference between Android's menu button, and some button that is part of your app. You need to click one or the other no matter what ... ?


I mean if i use normal button it always appear in the screen,but if i use menu option it doesn't always appear.we need to pop them.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41823
    
  63
Still not following. What kind of device do you have that does not always show the options menu button (or the overflow menu button, depending on the Android version)?
Anna Harris
Greenhorn

Joined: Aug 21, 2012
Posts: 13
First I need to know that in which app the option menu is not working.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: optionmenu not working