我使用 processing.js 编写了一个 android 应用程序!我在银河选项卡中进行多点触控缩放时遇到问题!在移动设备中没有问题,但在银河选项卡中,每当我尝试缩放时都会收到此错误:
FATAL EXCEPTION: main
java.lang.IllegalArgumentException: pointerIndex out of range
at android.view.MotionEvent.nativeGetAxisValue(Native Method)
at android.view.MotionEvent.getX(MotionEvent.java:1549)
at changethispackage.beforesubmitting.tothemarket.u2.u2.surfaceTouchEvent(u2.java:633)
at apwidgets.MyScrollView.onTouchEvent(MyScrollView.java:20)
at android.view.View.dispatchTouchEvent(View.java:4626)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1554)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1320)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1862)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1286)
at android.app.Activity.dispatchTouchEvent(Activity.java:2315)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1835)
at android.view.View.dispatchPointerEvent(View.java:4694)
at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2419)
at android.view.ViewRoot.handleMessage(ViewRoot.java:2080)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4126)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
Can't parse this exception line:
FATAL EXCEPTION: main
这是缩放的代码:
boolean surfaceTouchEvent(MotionEvent event) {
pointNum=event.getPointerCount();
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_POINTER_DOWN:
// User is pressing down another finger.
float x11 = event.getX(0) - event.getX(1);
float y22 = event.getY(0) - event.getY(1);
z4 = sqrt(x11*x11+y22*y22);
break;
case MotionEvent.ACTION_POINTER_UP:
// User is released one of the fingers.
break;
case MotionEvent.ACTION_MOVE:
x1=event.getX(0);
x2=event.getX(1);
y1=event.getY(0);
y2=event.getY(1);
float x = event.getX(0) - event.getX(1);
float y= event.getY(0) - event.getY(1);
float z3 = sqrt(x*x+y*y);
println("z3:" + z3);
if (pointNum == 2 ) {
if ( z3 < z4 ) {
zoom = z3/z4;
}
else {
zoom = z3/z4;
}
zoom = constrain(zoom, 0, 100);
}
break;
}
return super.surfaceTouchEvent(event);
}
如果您知道问题,请提供帮助!