Question

We use ActionBar in application. It contains several menu items with icons. One of them is "Help" at top-right corner. It has sub-menu with some items. If user makes long-press on menu item then ActionBar shows tool-tip. Also on Android 4.4 if user clicks on menu-item with sub-menu and slide finger down it expands sub-menu.

For a while user sees both tool-tip and expanded sub-menu. The problem is that after clicking on one of sub-menu items root menu-item no longer work it doesn't expand sub-menu and even highlighted. However other menu-items on ActionBar still works. Seems it's bug in Android's ActionBar implementation. Both tool-tip and sub-menu got some new animation effects on Android 4.4 so maybe some concurrency problem with them.

I'm currently looking for any workarounds. Any help will be appreciated.

Menu xml declaration.

<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:id="@+id/rate"
        android:icon="@drawable/rate_button_bg"
        android:title="@string/menu_rate_title"
        android:showAsAction="always" />

    <item
        android:id="@+id/like"
        android:icon="@drawable/like_button_bg"
        android:title="@string/menu_like_title"
        android:showAsAction="always" />

    <item
        android:id="@+id/share"
        android:icon="@drawable/share_button_bg"
        android:title="@string/menu_share_title"
        android:showAsAction="always" />

    <item
        android:id="@+id/help"
        android:icon="@drawable/global_icon_help"
        android:title="@string/menu_help_title"
        android:showAsAction="always">
        <menu>
            <item
                android:id="@+id/item_quick_start"
                android:showAsAction="always"
                android:title="@string/quick_start_tour_text" />

            <item
                android:id="@+id/item_faq"
                android:showAsAction="always"
                android:title="@string/frequently_asked_questions_text" />

            <item
                android:id="@+id/item_help"
                android:showAsAction="always"
                android:title="@string/contact_customer_support_text" />

        </menu>
    </item>

</menu>

Create menu:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_home, menu);
    return true;
}

Process clicks:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (R.id.item_quick_start == item.getItemId()) {
        // do some stuff
        return true;
    } else if (R.id.item_faq == item.getItemId()) {
       // do some stuff            
       return true;
      ...
    } else {
        // Default value
        return super.onOptionsItemSelected(item);
    }
}
Was it helpful?

Solution

Found workaround. If I call invalidateOptionsMenu(); then menu item remains to work.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (R.id.item_quick_start == item.getItemId()) {
        // do some stuff
        invalidateOptionsMenu();
        return true;
    } else if (R.id.item_faq == item.getItemId()) {
       // do some stuff            
       invalidateOptionsMenu();
       return true;
      ...
    } else {
        // Default value
        return super.onOptionsItemSelected(item);
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top