0

I've searched alot around the internet. I've done what I had to, but still I'm unable to show the 3 dotted menu as I want.

Here's the relevant code:

First, my manifest min sdk is set to 9 and my targetSdk is set to 18.

The menu xml:

<menu xmlns:android="http://schemas.android.com/apk/res/android" >

 <item
    android:id="@+id/itemMainAlbum"
    android:showAsAction="ifRoom"
    android:title="Set as Main Album">
</item>
<item
    android:id="@+id/itemImport"
    android:showAsAction="ifRoom"
    android:title="Import">
</item>
<item
    android:id="@+id/itemSettings"
    android:showAsAction="ifRoom"
    android:title="Settings">
</item>

The Activity's relevent code (extends SherlockActivity):

@Override
    public boolean onCreateOptionsMenu(Menu menu) {
       MenuInflater inflater = getSupportMenuInflater();
       inflater.inflate(R.menu.gallery_menu, menu);
       return super.onCreateOptionsMenu(menu);
    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
       // Handle item selection
       switch (item.getItemId()) {
          case R.id.itemImport:
             startImportActivity();
             return true;
          case R.id.itemMainAlbum:
              setMainAlbum();
             return true;
          case R.id.itemSettings:
                 // do s.th.
              return true;
          default:
             return super.onOptionsItemSelected(item);
       }
    }

Here's how my activity looks like:

enter image description here

The menu item in the bottom is shown only when I click on my device's menu button. The 3 dotted menu is just never shown, no matter how many menu items I add.

idish
  • 3,190
  • 12
  • 53
  • 85
  • 2
    If your device has a menu button it operates as you described. If there's no menu button it will show the 3 dotted overflow menu. – dymmeh Jul 29 '13 at 17:46

2 Answers2

1

The "3 dotted menu" will never be shown, as your device has a MENU button. The "3 dotted menu" will only appear on devices that lack a MENU button, to allow such users the ability to access the overflow. You can see what the "3 dotted menu" looks like by setting up an emulator that emulates a device with no MENU button.

You can read more about this in the "Say Goodbye to the MENU Button" Android Developers Blog post.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • This makes nonsense to me, most of the apps that I checked, do have the famous 3 dotted menu in their app. and it drop-downs also, when I click my menu button. – idish Jul 29 '13 at 17:52
  • @idish: Those apps are violating the UI guidelines for Android, and they hacked something in themselves. – CommonsWare Jul 29 '13 at 17:53
  • 1
    My main fear is that without that menu, users won't know that there is actually a menu they can use(Like, it's hidden from the users..). BTW, most of the devices have a menu button? – idish Jul 29 '13 at 17:55
  • @idish: I have not researched this, as I would never do it. I seem to recall that older versions of ActionBarSherlock supported this (later dropped). I have no idea if it is possible with the new AppCompat backport (I doubt it) and I have no idea if it is possible with the native action bar. You are always welcome to write your own "action bar", or to skip the action bar entirely and do something else. – CommonsWare Jul 29 '13 at 17:56
  • @idish: "My main fear is that without that menu, users won't know that there is actually a menu they can use" -- users are used to this. "BTW, most of the devices have a menu button?" -- all Android 1.x/2.x devices have a MENU button. Most Samsung phones have a MENU button. Many HTC phones have a MENU button. Hence, I would say that most devices have a MENU button, though certainly not all. – CommonsWare Jul 29 '13 at 17:58
  • As a professional android developer(You've helped me alot in the past). Do you think that it is OK to show the menu only when menu button is pressed? Maybe you think I just should use an older version of the ActionBarSherlock? – idish Jul 29 '13 at 18:00
  • @idish: "Do you think that it is OK to show the menu only when menu button is pressed?" -- yes. – CommonsWare Jul 29 '13 at 18:01
  • Thank you for your answer, you're doing a great job helping people. – idish Jul 29 '13 at 18:25
  • BTW, if you're interested the top answer hacks the new ActionBarSherlock with that. – idish Jul 29 '13 at 18:28
1

If you use ActionBarSherlock, you can use this little hack. It works flawlessly for me and shows the menuoverflow on every device I have tested it on.

Community
  • 1
  • 1
TheWizKid95
  • 721
  • 6
  • 16
  • Wow, that's great. It works. I've been searching for really long time. Can't believe I haven't found that one. Thanks alot! – idish Jul 29 '13 at 18:24