Question

I have a ListActivity as my main activity. I want to be able to do a few things on a single item in the list i.e.

Longpress to bring up a contextmenu for that item Swipe left to right to slide a new screen from the right to edit the list item.

Does anyone have any code they can show me that does this?

Was it helpful?

Solution

Longpress to bring up a contextmenu for that item

See here for how to use context menus. Here is a sample project that demonstrates their use.

Swipe left to right to slide a new screen from the right to edit the list item.

See here for how to use gesture libraries. Here is a ViewSwiper that adds gestures to a ViewFlipper. Here is an implementation of a drag-and-drop ListView, based on some poorly-understood code culled from Android itself. Blending all of that together, you may be able to implement what you seek. However, this will be rather difficult, and may not result in a user interface that is very usable. I strongly encourage you to simply have list item clicks be the way to indicate to edit an item, not a gesture.

OTHER TIPS

I think You can use a 2 Child ViewFlipper as your Listitem. one child for a normal dispaly(a TextView maybe), another a EditText. and in case it work as you said, don't forget to set gesterListener on your ViewFlipper,do showNext or showPrevious in your OnFling method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top