Android menus – another look

Browsing the Android “Creating menus” guide. Bits of note:

  • Now I know what the “group” setting is for on menus. Grouping items doesn’t make any visual difference, but in code you can do things to the group as a whole – enable/disable, make visible, etc.; also can use them to define mutually exclusive radio buttons.
  • Menu items can be in checked/unchecked state (setCheckable) – this includes options menu items, however these don’t have checkbox indicators, have to change icon or otherwise indicate state of checked-ness manually.
  • You can set a menu option to automatically start an intent when selected; however I’m not sure how useful this is – is there any advantage over firing the intent from a normal menu-item-pressed callback? It seems like having multiple places to define menu item behavior would just be confusing. Hard to imagine a situation so dynamic that this would really be necessary. But actually, the docs give the example of having an unknown set of intents (depending on other apps installed) to handle something; the example that comes to my mind is “Share” options where you click on e.g. a link and you can share via IM, SMS, twitter, Facebook, etc if you have those apps installed. So there’s some valuable juju in such cases, but otherwise it seems unwise.
  • Something to verify: is onCreateContextMenu() called once for each item that’s long-pressed? i.e. can we potentially create different context menus per item? Given the checkability thing above, it would seem likely. Also the prepare menu. Something for me to experiment with.
  • Adding keyboard shortcuts – I’m wondering how many Android devices this is really going to be useful on? With a touchscreen it’s completely useless – worse, in fact, as it will be a distraction. But given there are Android netbooks in the works, I suppose there’ll be some cases with no touchscreen where a keyboard shortcut will be more accessible than navigation.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: