Is there any possible way to display the three dots menu in action bar on divices with hardware menu button? Like Samsung Galaxy etc.
Asked
Active
Viewed 1.4k times
4 Answers
4
Looks like your answer is at the link below. There's an explanation of why you wouldn't want to do it, and another answer providing a hack to do it anyway (on android 4.x devices).
How to force use of overflow menu on devices with menu button

Community
- 1
- 1

Eric Simonton
- 5,702
- 2
- 37
- 54
2
The guide says:
…
Menu items that are not promoted to an action item are available in the overflow menu, revealed by either the device Menu button (when available) or by an "overflow menu" button in the action bar (when the device does not include a Menu button).

Community
- 1
- 1
-
Yeah but I just want to test it. I want to know hot it will look on devices without this button. And the emulator is lagging so much so I'd prefer to use this method. – egst Jan 31 '13 at 20:45
-
@McSim I think it's impossible in case of your need. It's just a simple button which shows a list of sub menu items. (I wouldn't spend so much time to test it). – Jan 31 '13 at 20:49
1
In my app I have nested menu like:
//menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/three_dots_item"
android:icon="@drawable/ic_three_dots"
android:title="@string/title"
android:showAsAction="always">
<menu>
<!-- items to show -->
</menu>
</item>
</menu>
It's not real overflow, but it's a simple workaround.

Michał Z.
- 4,119
- 1
- 22
- 32
-
It's a good idea, but there will be two menues on devices without that button then, won't they? – egst Jan 31 '13 at 20:47
-
-
No, they won't. I have it done in my app and it works on Android 2.x with ActionBarSherlock and on Android 4.x with native ActionBar as well. I think that I would have two menus on Android 4.x but i don't, because when I have a lot of items on ActionBar, then in my menu.xml I put some of them in this "fake overflow" so my items always fits ActionBar size and I don't have real overflow. There is one more trick, if you want to have overflow only in vertical orientation and in horizontal you want to have more items visible on ActionBar. You can then create groups in menu.xml and show/hide them. – Michał Z. Jan 31 '13 at 20:54
-
@MichałZ. how do you know that there are too many items, and which items to put in this subMenu of the overflaw item? – android developer Aug 01 '13 at 11:34
-
@androiddeveloper Actually I don't know. I decided that I want to have for example max 2 items and if there are more I put them in fake overflow. But I think you could try doing it dynamically by measuring width of screen and depending on http://developer.android.com/design/patterns/actionbar.html (Action overflow paragraph) put as many items as you want to actionbar and the rest of them to overflow. – Michał Z. Aug 01 '13 at 16:17
0
This is worked for me
Use
<uses-sdk
android:minSdkVersion="8"
/>
instead of
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17"/>
in manifest xml

Sandeep Kumar P K
- 7,412
- 6
- 36
- 40