[android-developers] ListActivity implements OnItemLongClickListener

2009-10-14 Thread Lee Jarvis

I'm attempting to implement a long click listener on a list activity
that simply works the same way as when you long click on a contact in
your address book. That is, displaying an AlertDialog with a list of
options (one option might be to add the value clicked as a favorite or
something). I've attempted to use something like the following..
http://pastie.org/655392 I realize this is wrong and my implementation
is totally screwed up, but I'm getting really confused with how to
implement this. Any help would be great. Thanks

Regards,
Lee
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] ListActivity implements OnItemLongClickListener

2009-10-14 Thread Jason Proctor

yeah it would be great if the menu had a hidden field per item where 
you could stash an ID or something. seems not, but i suppose you 
could override the category or group ID etc.

one thing you could do is have a map of menu texts back to your list 
views. when the onContextItemSelected() goes off, get the menu title, 
and look at the map to find the appropriate list view. once you have 
that, you can ask it for anything.

seems like i'm missing something simple here though.



That works great, thankyou.

One more thing, though. I have tried to mess around with
onContextItemSelected() and attempted to get the original text from
the list item I clicked through the ContextMenuInfo interface, but
there doesn't seem to be a clear way to achieve this. All I basically
need to (lets say, set a favorite) is the title or string of the list
item I clicked to bring up the context menu.

Thanks.

On Oct 15, 1:00 am, Jason Proctor jason.android.li...@gmail.com
wrote:
  the dialog that comes up when you long-click on a contact is
  actually a contextual menu.

  i've done this in my app for much the same reason and it's
  straightforward. call activity.registerForContextMenu(view), then
  implement View.OnCreateContextualMenuListener in your activity. when
  the user long taps on view, onCreateContextMenu() gets called off
  your activity. you get passed a Menu reference, which you build
  according to your context. this gets shown, the user picks one, and
  so forth.

  hth

  I'm attempting to implement a long click listener on a list activity
  that simply works the same way as when you long click on a contact in
  your address book. That is, displaying an AlertDialog with a list of
  options (one option might be to add the value clicked as a favorite or
  something). I've attempted to use something like the following..
  http://pastie.org/655392I realize this is wrong and my implementation
  is totally screwed up, but I'm getting really confused with how to
  implement this. Any help would be great. Thanks

  Regards,
  Lee

  --
  jason.vp.engineering.particle


-- 
jason.vp.engineering.particle

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