Ankit Shah wrote:
> I have a ListActivity and using BaseAdapter i have populated ListItems
> (Single ListItem row contains 3 views: 1 ImageView <"icon">, 1
> TextView <"Title"> and 1 more TextView <"Description">).
>
> Now When I short click on a list item, I get the position via
> onListItemClick event. When I long click on the same listItem, the
> context menu comes up. The thing is that there is no info on the
> position (long click position/Index value).
Sure there is.
Call getMenuInfo() on the MenuItem, and cast it to an
AdapterView.AdapterContextMenuInfo. You can then get the id of the item
that was clicked upon.
Here's a snippet of code from one of my book examples:
@Override
public boolean onContextItemSelected(MenuItem item) {
switch (item.getItemId()) {
case DELETE_ID:
AdapterView.AdapterContextMenuInfo info=
(AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
delete(info.id);
return(true);
}
return(super.onOptionsItemSelected(item));
}
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy
Looking for Android opportunities? http://wiki.andmob.org/hado
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---