Show context menu from code behind

AnD picture AnD · Sep 12, 2010 · Viewed 20.6k times · Source

This might be a simple question, but I've been looking around and can't find the answer. Is there any code to show the context menu on Android from a code, instead of pressing the menu button? E.g. when I touch the screen then it'll call the context menu?

Answer

CommonsWare picture CommonsWare · Sep 12, 2010

Call openContextMenu() on your Activity whenever you want to open it. Note that this is a rather unusual UI pattern, one that your users may not expect.