1

Hi guys I am trying to add icons to the list of items in my context menu triggered when the user long clicks on a list view item.

The list is displaying fine along with the context menu, the only thing I seem to be having difficulty with is setting the icons. This is my context menu xml file.

<item android:id="@+id/delete_item" android:title="Delete" android:icon="@drawable/delete" />
<item android:id="@+id/edit_item" android:title="Edit"  android:icon="@drawable/edit"/>

The only thing I wonder that might be throwing it off is perhaps the image sizes, do they have to be a specific size?

@Override
public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.setHeaderTitle("Options");
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.context_menu, menu);
}
Javacadabra
  • 5,578
  • 15
  • 84
  • 152
  • possible duplicate of [Add Context Menu Icon in android](http://stackoverflow.com/questions/1245543/add-context-menu-icon-in-android) – Siddharth Lele Jan 16 '13 at 03:25

1 Answers1

1

See this link:

Add Context Menu Icon in android

Context menus do not support icons.

From the above SO question, there is a library that allow you to do something similar:

https://code.google.com/p/android-icon-context-menu/

Community
  • 1
  • 1
Tim Malseed
  • 6,003
  • 6
  • 48
  • 66