I am able to read flings in left or right directions on a listview and change that listview to a different listview. To do this I over rode onTouchEvent like the example above. The problem is that in order to detect a fling onTouch has to return true and consume the touch event. Once it returns true the listview's onclick behavior no longer works - in other words you cannot indicate to a user which list item was touched.
public boolean onTouchEvent(MotionEvent event){ if (mGestureDetector.onTouchEvent(event)) { return true; } return super.onTouchEvent(event); } Also for fling to be detected, Gesturedetector's onDown should return true. On Nov 18 2008, 6:24 am, "Mr. Gallagher" <michaelpgallag...@gmail.com> wrote: > Would you be able to apply that gesture recognition to a list item? > > On Nov 6, 9:39 am, joshv <jvanderb...@gmail.com> wrote: > > > Actually I've found the following works well: > > > @Override > > public boolean dispatchTouchEvent(MotionEvent ev){ > > gd.onTouchEvent(ev); > > return super.dispatchTouchEvent(ev); > > } > > > calling super.dispatchTouchEvent allows all of the other views to > > receive their events. > > > For some reason, in my layouts, onTouch is never called for the > > Activity, so this is the only way I've found to detect gestures on the > > Activity. > > > On Nov 3, 4:07 pm, Rohit Mordani <mord...@gmail.com> wrote: > > > > yi, doing that will disable all normal touch event dispatching for > > > thatviewand any of its children. It's really rare that you should > > > override a dispatch method, especially doing so and never calling > > > through to the super class. > > > > The correct thing is almost always to override onTouchEvent(). > > > > Rohit > > > > On Oct 31, 1:05 pm, Rohit Mordani <mord...@gmail.com> wrote: > > > > > In addition you need to do the following in yourview: > > > > > @Override > > > > public boolean dispatchTouchEvent(MotionEvent ev){ > > > > return mGestureDetector.onTouchEvent(ev); > > > > > } > > > > > Thanks > > > > Rohit > > > > > On Oct 31, 2:01 pm, Rohit Mordani <mord...@gmail.com> wrote: > > > > > > I got fling/swipe to work. In one of my other posts someone told me to > > > > > do the following to make the onFling and Scroll methods to be called: > > > > > > 1) SetView.setLongClickable to true for theviewyou are using > > > > > 2) Set GestureHandler.setIsLongpressEnabled to true > > > > > 3) Return true in your onDown method > > > > > > Thanks for all the help > > > > > Rohit > > > > > > On Oct 30, 5:12 pm, Romain Guy <romain...@google.com> wrote: > > > > > > > A fling is just an ACTION_DOWN, one or more ACTION_MOVE and an > > > > > > ACTION_UP. It has nothing to do with running in the emulator or not. > > > > > > (For what it's worth, a large part of the touch UI and APIs have > > > > > > been > > > > > > developed in the emulator.) > > > > > > > On Thu, Oct 30, 2008 at 4:18 PM, Rohit Mordani <mord...@gmail.com> > > > > > > wrote: > > > > > > > > I THINK the problem is that in the emulator, pressing the left > > > > > > > mouse > > > > > > > button is more like a tap and that sets the MotionEvent.Action to > > > > > > > be > > > > > > > ACTION_DOWN. As a result the onDown() method of the > > > > > > > OnGestureListener > > > > > > > is called instead of onFling(). There might be a way to emulate > > > > > > > the > > > > > > > fling in the emulator but I am not sure of it. If anyone finds out > > > > > > > then please let me know. That would then call onFling() correctly > > > > > > > I > > > > > > > think > > > > > > > > Rohit > > > > > > > > On Sep 22, 6:40 am, kingtut <elzoha...@gmail.com> wrote: > > > > > > >> Any luck in getting the onFling or onScroll event to fire? I am > > > > > > >> facing > > > > > > >> the same problem. > > > > > > > >> On Sep 12, 5:14 pm, Mark Hansen <stonedon...@gmail.com> wrote: > > > > > > > >> > Ok, I'll keep trying it.. for some reason the events aren't > > > > > > >> > firing > > > > > > >> > such as Fling etc. > > > > > > > >> > On Sep 12, 10:12 am, Kavi <kavikbach...@gmail.com> wrote: > > > > > > > >> > > ListView is a kind ofView, so you should be able to attach > > > > > > >> > > the > > > > > > >> > > GestureDetector to your ListView as well. > > > > > > > -- > > > > > > Romain Guywww.curious-creature.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---