LeftNavBar doesn't honor android:showAsAction="always"

925 Views Asked by At

I'm using the following menu XML in my project:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/user_cp"
        android:icon="@drawable/gear"
        android:showAsAction="always" 
        android:title="@string/usercp"
        />
    <item 
        android:id="@+id/pm" 
        android:icon="@drawable/sym_action_email" 
        android:showAsAction="always" 
        android:title="@string/private_message"
        />
    <item
        android:id="@+id/refresh"
        android:icon="@drawable/ic_menu_refresh"
        android:title="@string/refresh" 
        />
    <item
        android:id="@+id/settings"
        android:icon="@drawable/ic_menu_preferences"
        android:title="@string/settings" 
        />
    <item
        android:id="@+id/logout"
        android:icon="@drawable/ic_menu_logout"
        android:title="@string/logout" 
        />
</menu>

When I my application loads up on Google TV (emulator or an actual device) LeftNavBarLibrary (http://code.google.com/p/googletv-android-samples/source/browse/LeftNavBarLibrary) ignores the android:showAsAction="always" property set for the first two menu items. These items are always placed inside the soft menu. Looking in LeftNavBarLibrary, in OptionsDisplay.java I see this reference to the "Show always" menu options and nothing else:

private void refreshExpandedState() {
    // Menu icon.
    setOptionExpanded(mView.getChildAt(1), mExpanded);
    // "Show always" options.
    ViewGroup optionsContainer = getOptionsContainer();
    for (int i = 0; i < optionsContainer.getChildCount(); ++i) {
        setOptionExpanded(optionsContainer.getChildAt(i), mExpanded);
    }
}

Does this feature work with LeftNavBarLibrary or am I stuck implementing it myself? It's critical for this app that I use action items on the ActionBar in certain cases since the buttons are actual actions and not something that can be replaced with a tab.

Edit: Looks like LeftNavBarLibrary doesn't truly honor the options menu at all, it will show the options button regardless of whether or not it needs to.

1

There are 1 best solutions below

0
On BEST ANSWER

You should not be able to place action items on LeftNavBar , it would always show as ordinary Option menu item.