Context Menu with Icons
In Android, context menus (1) can't have icons (2) cannot be flexibly created and destroyed. With this embeddable library, you get a context menu that solves both problems.
Sample (from Hi-Q MP3 Recorder):
Consistency to Android platform is maintained by not using custom layouts, instead it uses internal layouts only.
How to use
You can easily add this project as a library project in Eclipse.
- Create a menu in XML as what you would do when you create a normal (options) menu. Specify the drawables as usual. You can also create the menu on-the-fly by using MenuBuilder which implements Menu.
- Create the Context Menu with Icons by calling IconContextMenu cm = new IconContextMenu(context, R.menu.contextmenu)
- Create, and then set the context menu handler by calling setOnIconContextItemSelectedListener(IconContextItemSelectedListener).
- (Optional) set additional info to differentiate sources, e.g. the position of the item on the list that was clicked. cm.setInfo(position)
- Open the context menu by calling show().
See also other projects for Android: