Search code examples
androidandroid-actionbaractionbarsherlockmenuitem

How to know if MenuItem is in ActionBar or Overflow


First of, I'm using SherlockActionBar.

I've one MenuItem that is 'always' showed in the ActionBar and one other MenuItem that is only showed 'ifRoom'. There are also other MenuItems that are 'never' showed in the ActionBar and therefore there exists a Overflow Icon (if device has no hardwarebutton).

My question now is, how am I able to tell if the MenuItem with 'ifRoom' is currently showed or not in the ActionBar (in ActionBar or Overflow?)? I need to know that because I'm using the ShowcaseView Library to highlight these options. Therefore I have to know if I should highlight the Overflow or I can directly target to the MenuItem.

Thx


Solution

  • Imo there is no way to know if a menu entry is on the overflow menu via an API.

    Even with "never" you can still be pushed into the overflow menu when the the title is long and your device is very narrow.

    What you could try is to place an action view into your menu items and get its position on screen. If not on screen you can be certain it is pushed into the overflow menu.