1

at the moment i'm trying to write an app which has a listview, and if i swipe especially left the listitem switches to another xml like it's used in the twitter app.

Especially i have a list of items only with some text and when i swipe left on a single item it changes to an other item (via a xml-file) especially with some buttons or anything else.

I hope anyone, has an idea how i can do this?

Thanks.

mikepenz
  • 12,708
  • 14
  • 77
  • 117
  • 1
    This might help: http://stackoverflow.com/questions/4030389/how-to-implement-fling-in-android-listview , or this: http://stackoverflow.com/questions/1338475/how-to-best-handle-fling-gesture-for-android-listactivity – Charlie Collins Feb 08 '11 at 14:57
  • I've seen this post before but i'm not sure if this is the function i'm looking for. Because i think i can't change the XML-Layout of the ListItem where i did the swipe? My problem isn't the swipe gesture, the problem is that i don't know how to change the layout? – mikepenz Feb 08 '11 at 15:01

1 Answers1

1

I have seen this done using a Gallery set to fill_parent. Care has to be taken to allow child views to pass on touch events appropriately for swiping to work. Note that Gallery is a subclass of ViewGroup.

EDIT: see comment below, i should've checked the twitter app first!

Dori
  • 18,283
  • 17
  • 74
  • 116
  • i think that's not the thing i am searching for, because if i have as an example 200 list-items i would need 200 gallery listitems that's a little bit much. don't you know a simple solution with which i can only change the xml-layouts in a listview item? – mikepenz Feb 08 '11 at 15:42
  • sorry, i shoudve checked the twitter app first. You can use a RelativeLayout with two ViewGroups inside - both set to fill the parent (so one will be in front of the other). When you detect the swipe gesture you can then animate the top layout however you wish (x or y position, alpha, transformation etc) to leave the underlying view (in this case the gray buttons in the twitter app) visible and accessable. Be careful though as users may not know this action is possible, i didnt know it could be done on the twitter app and as its not standard nor will many other users i imagine. – Dori Feb 08 '11 at 17:33