I noticed that in my app when I add a menu for new devices that dont have a hardware menu button it adds the three dots to the actionbar. However, I see on some apps that you can actually move those three dots to the bottom (on the software navigation)
How can this be achieved? I am using actionbarsherlock as well if that makes a difference.
Asked
Active
Viewed 5,180 times
4

HAxxor
- 1,164
- 3
- 16
- 28
-
It's pretty vague can you elaborate more what app menu are you building? – Akyl Oct 26 '12 at 19:05
-
The menu button. I'll attach a picture. – HAxxor Oct 26 '12 at 19:11
-
Do you mean ActionBars [like these](http://developer.android.com/design/media/action_bar_pattern_rotation.png), specifically the one in the front-left? – Sam Oct 26 '12 at 19:11
-
Edited my desc with an image. – HAxxor Oct 26 '12 at 19:11
-
So do you want to make this menu bar? this is prebuilt with android phones some I know are a bit different or do you want to get a specific result – Akyl Oct 26 '12 at 19:17
-
Right now the three dots are in the actionbar on my Google Nexus (which doesnt have a hardware menu button). Instead of the three dots showing in the menu I want it to be shown in the software buttons like the picture above. How can I set this? – HAxxor Oct 26 '12 at 19:21
2 Answers
7
You can "achieve" this by setting your targetSdk
below 14. I say "achieve", because this is bad practice. For devices that have software keys, as long as you're using a theme with the ActionBar, it will display the menu on the ActionBar. If you're using a theme without the ActionBar (non-Holo), it will display the three dots.
The three dots are hated.
The three dots are evil.
The three dots must. be. eradicated.
In short, I'd avoid it. :)
See also: Menu Button of Shame

Kevin Coppock
- 133,643
- 45
- 263
- 274
-
Thank you. Yes if I put my target sdk below 14 it breaks a lot of stuff. Welp... this sucks. Guess I am not going this route. haha. Thanks for the answer. – HAxxor Oct 26 '12 at 19:22
-
No problem. :) Why does it suck? Just curious, what's your goal? Why are you wanting them at the bottom? – Kevin Coppock Oct 26 '12 at 19:23
-
To be honest I would guess that he is doing it for a game. as the 3 buttons looks distracting. – Akyl Oct 26 '12 at 19:34
-
It looks kind of awkward on my application, especially since I have another icon there. So the addition of the three dots just makes it look very ugly. – HAxxor Oct 26 '12 at 19:35
-
-
The three dots are not hated and are part of Google's suggested implementation: http://developer.android.com/guide/topics/ui/menus.html#options-menu – Kenny Wyland Apr 08 '13 at 18:56
-
@KennyWyland Different three-dots that we're talking about. The three-dot menu in the software keys == bad. Three-dot overflow menu in the action bar == good. – Kevin Coppock Apr 08 '13 at 19:21
1
So, turns out it's pretty simple, I recently implemented in my app.
The items that need to be shown in the overflow menu, nest them under one menu item as follows:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/empty"
android:orderInCategory="101"
android:showAsAction="always"
android:icon="@drawable/ic_action_overflow">
<menu>
<item
android:id="@+id/action_settings"
android:orderInCategory="96"
android:showAsAction="never"
android:title="@string/menu_settings"
android:icon="@drawable/ic_action_settings"/>
<item
android:id="@+id/action_share"
android:orderInCategory="97"
android:showAsAction="never"
android:title="@string/menu_share"
android:icon="@drawable/ic_action_share"/>
<item
android:id="@+id/action_rate"
android:orderInCategory="98"
android:showAsAction="never"
android:title="@string/menu_rate"
android:icon="@drawable/ic_action_important"/>
<item
android:id="@+id/action_feedback"
android:orderInCategory="99"
android:showAsAction="never"
android:title="@string/menu_feedback"
android:icon="@drawable/ic_action_edit"/>
</menu>
</item>
</menu>
Now, edit the main activity file as follows:
package com.example.test;
//all your import statements go here
Menu mainMenu=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
mainMenu=menu;
return true; }
//Menu press should open 3 dot menu
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode==KeyEvent.KEYCODE_MENU) {
mainMenu.performIdentifierAction(R.id.empty, 0);
return true; }
return super.onKeyDown(keyCode, event); }

Andrew Barber
- 39,603
- 20
- 94
- 123

sravan953
- 191
- 3
- 14