0

Basically I am inflating a menu

public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    globalMenu = menu;
    getSupportMenuInflater().inflate(R.layout.menu_refresh, menu);
    return super.onPrepareOptionsMenu(menu);
}

menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:id="@+id/menu_refresh"
        android:showAsAction="never"
        android:title="@string/refresh"/>
    <item
        android:id="@+id/menu_24hours"
        android:showAsAction="never"
        android:title="@string/twentyfour_hours"/>
     <item
        android:id="@+id/menu_1week"
        android:showAsAction="never"
        android:title="@string/one_week"/>
    <item
        android:id="@+id/menu_1month"
        android:showAsAction="never"
        android:title="@string/one_month"/>
    <item
        android:id="@+id/menu_3month"
        android:showAsAction="never"
        android:title="@string/three_month"/>
    <item
        android:id="@+id/menu_6month"
        android:showAsAction="never"
        android:title="@string/six_month"/>

</menu>

whats happening, is that none of them are showing in 3 dots format.In ice cream sandwich you have to click the button menu on hardware, in nexus it shows 3 dots.. i need everywhere to have it as 3 dots, no device uniqueness.

However if i do this in my menu...

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/menu_refresh"
        android:showAsAction="always"
        android:icon="@drawable/ic_action_refresh_default" />
</menu>

this shows up in actionbardsherlock on top, on all devices. no menu hardware key.

Mattia Maestrini
  • 32,270
  • 15
  • 87
  • 94
user3278732
  • 1,694
  • 10
  • 31
  • 67

2 Answers2

1

Try creating dummy actionButton which have 3 dots as the icon. This is what I do if I need 3 dots button to be shown on all devices (Especially Samsung devices which have hardware menu keys). Note that this is actually a hack

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:id="@+id/menu_dummy_overflow"
    android:icon="@drawable/ic_action_ic_overflow"
    android:showAsAction="always"
    android:title="@string/more">
    <menu>
        <item
            android:id="@+id/menu_open_browser"
            android:icon="@drawable/ic_action_ic_browser"
            android:showAsAction="never"
            android:title="@string/opeinInBrowser">
        </item>
    </menu>
</item>
</menu>
Malvin
  • 692
  • 5
  • 8
0

This is something that's decided by the Android OS build that is running. The bad news is that it means you have little control over it. The good news is that it means the user will see the same behaviour on every app on their phone, so they will be expecting it anyway.

You could mimic the behaviour by manually adding an overflow item to your menu and putting your overflow items into a sub-menu of that item. The downside of this is that the number of items you show is fixed. You won't get the benefit of a tablet in landscape mode showing more items in the ActionBar

Denley Bihari
  • 591
  • 3
  • 8