Friday, September 9, 2011

[android-developers] Re: onTouchEvent method is not working

When you drag, ACTION_MOVE actions are called over a specific interval
depending on the device (~20ms)... its possible that these are the
gaps you are seeing on the emulator.

On Sep 8, 7:47 am, Anoop Singh <anoop.singh.k...@gmail.com> wrote:
> I am working on a drawing application. When I touch on screen
> primitive is drawing properly but when I am dragging on emulator
> screen only few times onTouch event is called.
> // mPaint is a Paint object.
>         @Override
>         public boolean onTouchEvent(MotionEvent event) {
>                    float x = event.getX();
>                    float y = event.getY();
>
>             switch (event.getAction()) {
>                 case MotionEvent.ACTION_DOWN:
>                         mCanvas.drawBitmap(primitive, x, y, mPaint);
>                           touch_start(x, y);
>                                   invalidate();
>                            break;
>                 case MotionEvent.ACTION_MOVE:
>                         mCanvas.drawBitmap(primitive, x, y,
> mPaint);                                                                 invalidate();
>                           break;
>                 case MotionEvent.ACTION_UP:
>                              mCanvas.drawBitmap(primitive, x, y, mPaint);
>                                 invalidate();
>                                 break;
>                         }
>                         return true;
>                 }

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment