Um, I want to use dispatchTouchEvent() to implement a gesture system,
so I have code like this:

        public boolean dispatchTouchEvent(MotionEvent ev) {
                boolean rtn = mGesture.onTouchEvent(ev);

                if (ev.getAction() == MotionEvent.ACTION_UP) {
                        Log.v("dispatch", "Gesture=" + 
mGesture.getGestureString());
                        if(mGesture.getGestureString().equals("")) {
                                return super.dispatchTouchEvent(ev);
                        }
                }

                return rtn;
        }

which means, if the gesture is empty (indicates a click), I want to do
original things like onListItemClick().
But calling super.dispatchTouchEvent(ev); will not trigger
onListItemClick(). So what I want to do is:

If it's a simple click, call onListItemClick().
Otherwise, call dispatchTouchEvent().

Thanks for replying. (Sorry for my poor English since I'm not a native
English speaker)

On 9 $B7n (B19 $BF| (B,  $B2<8a (B4 $B;~ (B02 $BJ, (B, hackbod <[EMAIL 
PROTECTED]> wrote:
> Well yes, dispatchTouchEvent() dispatching touch events through the
> view.  If you do this:
>
> @Override public boolean dispatchTouchEvent(MotionEvent ev) {
>     return super.dispatchTouchEvent(ev);
>
> }
>
> it will behave exactly the same as if you didn't override the method,
> so I'm not sure what you mean by it not working.
>
> What are you trying to accomplish?
>
> On Sep 19, 12:12 am, Urakagi <[EMAIL PROTECTED]> wrote:
>
> > Hi, I have a class extending ListActivity, and I want to catch
> > touchevent on it so I override dispatchTouchEvent.
>
> > @Override
> > public boolean dispatchTouchEvent(MotionEvent ev) {
> >   ...
>
> > }
>
> > And since it's a ListActivity, of cource I want to override the
> > onListItemClick(), too:
> > @Override
> > protected void onListItemClick(ListView l, View v, int position, long
> > id) {
> >   ...
>
> > }
>
> > But now I find that the dispatchTouchEvent() will intercept ALL touch
> > event on the activity, so onListItemClick() will never be called.
> > I tried
> >  super.dispatchTouchEvent(ev);
> > but it does not work.
>
> > Anyone has any idea for this? Thanks!
--~--~---------~--~----~------------~-------~--~----~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to