Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

optionmenu not working

 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • 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"
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
Menu.gif
[Thumbnail for Menu.gif]
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens when you press the Menu button on the emulator?
 
sam liya
Ranch Hand
Posts: 1240
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • 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.
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • 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.
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • 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: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • 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 ... ?
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • 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)?
 
Anna Harris
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First I need to know that in which app the option menu is not working.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic