0

The following code is the actual code used in an test app, on a class that extends surfaceView.

@Override
public void onDraw(Canvas canvas)
{       
    canvas.drawCircle(touched_x, touched_y, 50, myPaint);
}

@Override
public boolean onTouchEvent(MotionEvent event)
{
    touched_x = event.getX();
    touched_y = event.getY();  
    return true;    
}

It basically draws where your finger goes. To test if its tracking or not.

Adding a second finger, and you can still tracks your first. But add a 3rd, and it just stops. It doesnt matter what you do from there. Unless you remove all fingers and start again it wont track.

Now this is a problem since it sometimes thinks one finger is three! I can overcome this testing distance between fingers, but still, this doesnt resolve the problem.

When the third finger hits and it freezes tracking. It doesnt invoke action.Cancel.

Its vital that I know where and when the 1st finger is released.

However it thinks the last event was MotionEvent.ACTION_MOVE. Not MotionEvent.ACTION_UP or MotionEvent.ACTION_CANCEL.

Currently since one finger can be three. My app just will seem like it failed to load a given image scroll.

IAmGroot
  • 13,760
  • 18
  • 84
  • 154

1 Answers1

0

post more of your code. I'm not getting any problems. Maybe you forgot to invalidate view in some cases or there is a mistake? There is my full code and it works:

float x1 = -100, y1;

@Override
protected void onDraw(Canvas canvas) {
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    canvas.drawColor(Color.WHITE);

    paint.setColor(Color.RED);
    canvas.drawCircle(x1, y1, 30, paint);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    x1 = event.getX();
    y1 = event.getY();

    invalidate();
    return true;
}

Maybe you have bugs on your device, but that's unlikely..

alaster
  • 3,821
  • 3
  • 24
  • 32