On Sun, Feb 21, 2010 at 10:30 AM, NoraBora <[email protected]> wrote:

> Are you using this code?
>
> AdapterContextMenuInfo info = (AdapterContextMenuInfo)
> item.getMenuInfo();
>
> For ExpandableListView, you have to use ExpandableListContextMenuInfo.
>

Yup. Here's a sample:

@Override
public void onCreateContextMenu(ContextMenu m, View v, ContextMenuInfo i)
{

...
ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) i;
...

}

This part works great when the context menu is created. I get the
ExpandableListContextMenuInfo object and get get the index of the group or
child that was selected for the context menu.

However this:

@Override
public boolean onContextItemSelected(MenuItem item)
{

...
ContextMenuInfo i = item.getMenuInfo();
ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) i;
...

}

only works when the item coming in is one of the main items in the context
menu. If it is a sub-menu item, the variable i is null.

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to