Overflow Actions on ActionBar not showing

I have an ActionBar using ActionBar Sherlock where I need it to display overflow because I have more actions than room. But, it doesn't show the overflow icon. Here is my configuration:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_search"
      android:icon="@drawable/action_search"
      android:title="@string/menu_search"
      android:showAsAction="ifRoom|withText"/>
<item android:id="@+id/menu_library"
      android:icon="@drawable/hardware_headphones"
      android:title="@string/my_music"
      android:showAsAction="ifRoom|withText"/>
<item android:id="@+id/menu_downloads"
      android:icon="@drawable/av_download"
      android:title="@string/downloads"
      android:showAsAction="ifRoom|withText"/>
</menu>

And here is code to set it up:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = getSupportMenuInflater();
    menuInflater.inflate(R.menu.shopping_menu, menu);
    MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
    searchMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            startActivity(new Intent(ShopActivity.this, SearchDialog.class));
            return false;
        }
    });
    MenuItem downloadMenuItem = menu.findItem(R.id.menu_downloads);
    downloadMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            startActivity( new Intent(ShopActivity.this, DownloadQueueActivity.class) );
            return false;
        }
    });
    MenuItem myMusicItem = menu.findItem(R.id.menu_library);
    myMusicItem.setOnMenuItemClickListener( new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            startActivity(new Intent(ShopActivity.this, MyMusicActivity.class));
            return false;
        }
    });

    return true;
}

I've looked over the demos in ActionBar Sherlock, but I can't tell what they do differently to get the overflow than what I'm doing. So what's happening here why its not showing?

Answers


If you have a physical menu key, the overflow indicator does not show. That is a behaviour by design. See here for more details on another question asked.


Hmm I think there are two issues here. First, as t0mm13b states, if the device has a physical menu key, the overflow indicator does NOT show. This is by design. Although in my experience, it doesn't apply to every device (unfortunately...)

The second issue is that, if you want to force an item to the overflow, you need to set the showAsAction to "never". Otherwise, the only elements that appear in the overflow are ones that simply "don't fit" in the action bar. And given that you have 3 items that you want to display with text.. you're pretty much guranteed to have at least one overflow item, and therefore the overflow icon (with the caveat of the first paragraph)


Try by changing the android:showAsAction tag to app:showAsAction according to the Android guide in the menu_main.xml file as shown below

Add this line if not present

menu xmlns:app="http://schemas.android.com/apk/res-auto"

    <item android:id="@+id/action_search"
        android:icon="@drawable/search_icon"
        android:title="@string/action_search"
        app:showAsAction="always"/> <!--change here android: to app:-->

    <item android:id="@+id/action_location"
        android:icon="@drawable/location_icon"
        android:title="@string/action_locate"
        app:showAsAction="always"/>
</menu>

Need Your Help

How to create an Excel File with Nodejs?

excel node.js file-io export-to-excel npm

I am a nodejs programmer . Now I have a table of data that I want to save in Excel File format . How do I go about doing this ?

My Magento Extension Install Script Will Not Run

php magento attributes installation install

I am trying to create an install script for my extension and for some reason it will not the install script. The extension will show up in the core_resource table, but the attributes I am trying to