简体   繁体   中英

LeftNavBar doesn't honor android:showAsAction=“always”

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.

您不应该在LeftNavBar上放置操作项,它将始终显示为普通的Option菜单项。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM