• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

optionmenu not working

 
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"
android:orientation="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
Menu.gif
[Thumbnail for Menu.gif]
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happens when you press the Menu button on the emulator?
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks,it gives the result.

http://i693.photobucket.com/albums/vv299/asliyanage/Menu2.gif?t=1366283192
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it's better to use button,if i need to see them without clicking Menu button.is it correct?
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ... ?
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)?
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First I need to know that in which app the option menu is not working.
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic