Hi,

I'm trying to use a GestureDetector in a subclass of FrameLayout,
which has a child ListView.
But it seems the GestureDetector has some side effect which causes
abnormal scrolling behaviors for the child ListView, e.g. sometime
when flinging down, the list actually scrolls upwards; when the list
is being flung (i.e. the scrolling animation is still playing) and you
press and hold on the list, the scroling stops (which is normal), but
as soon as you release, the list scrolls.

The code for the layout is shown below.  Apparently it actually does
nothing extra but calling GestureDetector.onTouchEvent().  If the line
"boolean handled = mGestureDetector.onTouchEvent(ev);" is commented
out, the child ListView will scroll as normal.  Is it because the call
to onTouchEvent() takes some time that confuses the child ListView?

Also, it seems this problem only occurs when the list item is complex,
e.g. consisting of multiple ImageViews, TextView etc.  Everything
works fine if it's just a list of TextView's.

public class MyLayout extends FrameLayout implements OnGestureListener
{
 ...
        @Override
        public boolean dispatchTouchEvent(MotionEvent ev) {
                boolean handled = mGestureDetector.onTouchEvent(ev);
                return super.dispatchTouchEvent(ev);
        }

        public void onShowPress(MotionEvent e) {
        }

        public boolean onSingleTapUp(MotionEvent e) {
                return false;
        }

        public void onLongPress(MotionEvent e) {
        }

        public boolean onDown(MotionEvent e) {
                return false;
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float
velocityX,
                        float velocityY) {
                return false;
        }

        public boolean onScroll(MotionEvent e1, MotionEvent e2, float
distanceX,
                        float distanceY) {
                return false;
        }
}


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to