Search code examples
androidactionbarsherlockandroid-actionbar

Manually open ActionBar navigation list


I have an ActionBarSherlock with navigation mode set to NAVIGATION_MODE_LIST and an adapter for it. The list shows up as expected.

The drop-down list appears when the user presses the item in the ActionBar, but I also need to be able to make the drop-down list appear when the user presses a hardware key (the menu key). I know how to get the key event but I can't seem to find any call to open the drop-down.

Is there any way to achieve this?


Solution

  • I don't think this is possible using the native ActionBar implementation. The Spinner that's placed in the ActionBar, when you're using that particular navigation type, is created in code. Because there's no special ID to reference, you couldn't call something like Spinner.performClick.

    Alternatively, you could inflate a custom layout for your ActionBar with a Spinner, override the Menu button, and call Spinner.performClick when that is pressed.

    References

    ActionBarView

    Spinner.performClick