1

So this is the deal, I have the following

enter image description here

And I want to remove it but still be able to access the menu item through the menu button, is this possible?

enter image description here

Here is my menu xml file

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:id="@+id/updateShares"
        android:orderInCategory="100"
        android:showAsAction="never"
       android:title="Refresh"/>        
</menu>

And here is my code creating the menu

@Override
    public boolean onCreateOptionsMenu(Menu menu){
      MenuInflater inflater = getMenuInflater();

      inflater.inflate(R.menu.activity_action_bar_main, menu);
        return true;
    }

EDIT_____________________________________________________________________

I still want the "refresh" menu to appear when you press the menu button on the phone, I just want to remove the menu bar, thats why I can't set any option menu to visible=false because then I can't see them when pressing the menu bar. enter image description here

anders
  • 1,535
  • 5
  • 19
  • 43

3 Answers3

0
  1. You can just add in your onCreate following snippet: this.requestWindowFeature(Window.FEATURE_NO_TITLE); so your title bar will gone.

  2. This may help you with removing menu item https://stackoverflow.com/a/13099201/1045579

Community
  • 1
  • 1
sztembi
  • 223
  • 2
  • 10
  • Cant do the first "this.requestWindowFeature(Window.FEATURE_NO_TITLE); " because then the Tabs are dissapearing The second MenuItem item = menu.findItem(R.id.updateShares); item.setVisible(false); Doesn't work because then the menu won't show when I press the Menu button on the phone. Any other suggestions? =) – anders Dec 10 '12 at 23:40
0

I am not sure with the mark166 answer. You can try this link also. And another thing what i have done and you can try is....

Just don't inflate the layout on click of Menu. Even dont create menu.xml file.

You can try with the following code in java file

@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        switch (keyCode) {
        case KeyEvent.KEYCODE_MENU:
            Toast.makeText(getApplicationContext(), "Do what you want to show here", Toast.LENGTH_SHORT).show();
            break;

        }
        return true;
    }

It works for me and using same thing in app.

You just comment your code for the menu and try this one.

Hope it will help you.

Shreyash Mahajan
  • 23,386
  • 35
  • 116
  • 188
0

as per your second screenshot change the target SDK version to 4.0.3 so the menu ... will not visible.

Dinesh T A
  • 2,087
  • 4
  • 26
  • 34