Hi, I'm interested in this topic. I have a question about the id that
returns from info.id. Is this id the same that is used by SQLite? As I
see in your example, that I suppose is taken from the developers
tutorial, you use info.id to delete an item from SQLite. But the
column in SQLite was named _id. Is this some kind of convention to
stick to? What if those items did not have an _id but a, suppose, _key
not called id? Could we do info.key?

On 15 Lug, 21:59, Mark Murphy <[email protected]> wrote:
> 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.AdapterContextMenuInfoinfo=
> (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
-~----------~----~----~----~------~----~------~--~---

Reply via email to