Implementing ics style menu pop ups for devices with a menu key

53 views
Skip to first unread message

Hugo Visser

unread,
Nov 14, 2012, 6:29:07 AM11/14/12
to actionba...@googlegroups.com
Hi,

I was wondering how hard it would be to emulate the ics style menu on devices with a menu key. That would not only make it look consistent across versions, but it would also mean that there's no menu icon juggling (as in separate menu.xml) for 2.x devices. A starting point would be overriding onCreatePanelView and the likes and managing the menu in SherlockActivity.
What I'm not sure about is how to integrate the abs menu stuff into a new pop up menu anchored at the right place, and what to reuse from abs, but I'm happy to take on the task ;)

Any hints, feedback would be appreciated.

Hugo


Jake Wharton

unread,
Nov 14, 2012, 7:07:40 AM11/14/12
to actionba...@googlegroups.com

This is already filled as #627 on the issue tracker

Hugo Visser

unread,
Nov 15, 2012, 6:50:14 AM11/15/12
to actionba...@googlegroups.com
Allright, that ticket basically says: do it like shown on the link, which is fine, but my question would be if I could reuse some of the styling and compatible pop up stuff from abs or if that would be a nogo. I mucked around with MenuPopupHelper today and it didn't really give me what I want, but I'd assume that it's sort of the same as showing the overflow menu but in a different place.

The referenced article describes a few things: setting up a custom menu view, setting up a custom menu inflater to get to the menu items and showing the actual menu. Since ActionBarSherlock already has a custom menu view (for the overflow) and has it's own inflater and menu / menu builder so my gut feeling would be it would be wise to hook into that since it's already in place.

I'm happy to work on it myself and contribute back, just need some pointers since I don't know all of the abs internals (although I'm learning those fast), that's all I'm asking ;) I've checked out the fennec source as well to look at that implementation later.

Thanks,

Hugo

Roberto

unread,
Nov 15, 2012, 12:26:45 PM11/15/12
to actionba...@googlegroups.com
What I do is implement the following on my base activities:

private Menu actionBarMenu;

@Override

public boolean onCreateOptionsMenu(Menu menu) {

actionBarMenu = menu;

}

 

@Override

public boolean onKeyUp(int keyCode, KeyEvent event) {

if (keyCode == KeyEvent.KEYCODE_MENU) {

showMenuOverlay();

return true;

}

return super.onKeyUp(keyCode, event);

}


private void showMenuOverlay() {

if (actionBarMenu != null) {

actionBarMenu.performIdentifierAction(R.string.menu_more, 0);

Reply all
Reply to author
Forward
0 new messages