2

ここに画像の説明を入力ListView Item でスワイプ削除しようとしています

onFling(MotionEvent e1、MotionEvent e2、floatのvelocityX、floatのvelocityY)、swinpingのMotionEvent e1でnullを取得しています

助けてください、事前に感謝します

@Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
            float velocityY) {
        Log.e(THIS_FILE, "======onFling "+REL_SWIPE_MAX_OFF_PATH+" , "+e1+" , "+e2);
        if (Math.abs(e1.getY() - e2.getY()) > REL_SWIPE_MAX_OFF_PATH)
            return false;
        if (e1.getX() - e2.getX() > REL_SWIPE_MIN_DISTANCE
                && Math.abs(velocityX) > REL_SWIPE_THRESHOLD_VELOCITY) {

            int pos = getListView()
                    .pointToPosition((int) e1.getX(), (int) e2.getY());

            if (pos >= 0 && temp_position == pos)
                getSwipeItem(false, pos);
        } else if (e2.getX() - e1.getX() > REL_SWIPE_MIN_DISTANCE
                && Math.abs(velocityX) > REL_SWIPE_THRESHOLD_VELOCITY) {

            int pos = getListView()
                    .pointToPosition((int) e1.getX(), (int) e2.getY());
            if (pos >= 0 && temp_position == pos)
                getSwipeItem(true, pos);

        }
        return false;
    }

ここに私のログがあります

09-05 14:41:45.086: E/DialerFragment(31827): ======onFling 333 , null , MotionEvent {     action=ACTION_UP, id[0]=0, x[0]=390.39392, y[0]=154.0, toolType[0]=TOOL_TYPE_FINGER,     buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0,     eventTime=197101507, downTime=197101342, deviceId=2, source=0x1002 }
09-05 14:41:45.086: E/InputEventReceiver(31827): Exception dispatching input event.
09-05 14:41:45.086: E/MessageQueue-JNI(31827): Exception in MessageQueue callback: handleReceiveCallback
09-05 14:41:45.116: E/MessageQueue-JNI(31827): java.lang.NullPointerException
09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at net.telivo.fiestacancun.ui.tablet.DialerFragment$MyGestureDetector.onFling(DialerFragment.java:    1660)
09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at     android.view.GestureDetector.onTouchEvent(GestureDetector.java:609)
      09-05 14:41:45.116: E/MessageQueue-JNI(31827):    at net.telivo.fiestacancun.ui.tablet.DialerFragment$12.onTouch(DialerFragment.java:967)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.View.dispatchTouchEvent(View.java:7379)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2203)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1938)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1952)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1952)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1952)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1952)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1952)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1952)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1952)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at     android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1952)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1952)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at    android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1952)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2209)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1952)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1966)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1418)
09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.app.Activity.dispatchTouchEvent(Activity.java:2424)
09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1914)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.View.dispatchPointerEvent(View.java:7564)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3883)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3778)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3483)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3540)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at     android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at     android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5419)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at     android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5399)
09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5370)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5493)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:182)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.os.MessageQueue.nativePollOnce(Native Method)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.os.MessageQueue.next(MessageQueue.java:132)
    09-05 14:41:45.116: E/MessageQueue-JNI(31827):  at android.os.Looper.l
    09-05 14:41:45.116: D/AndroidRuntime(31827): Shutting down VM
    09-05 14:41:45.116: W/dalvikvm(31827): threadid=1: thread exiting with uncaught exception (group=0x4184c700)
4

2 に答える 2

-1

あなたのログは e1 が null でありhistorySize=0、 であることを示しているため、報告するイベントは 1 つだけです。両方のイベントがあることを確認するには、null チェックを追加する必要があります。

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
        float velocityY) {
    Log.e(THIS_FILE, "======onFling "+REL_SWIPE_MAX_OFF_PATH+" , "+e1+" , "+e2);
    if (e1 == null || e2 == null) {
        return false;  // If it still gives you trouble return true
    }

    if (Math.abs(e1.getY() - e2.getY()) > REL_SWIPE_MAX_OFF_PATH)
        return false;
    if (e1.getX() - e2.getX() > REL_SWIPE_MIN_DISTANCE
            && Math.abs(velocityX) > REL_SWIPE_THRESHOLD_VELOCITY) {

        int pos = getListView()
                .pointToPosition((int) e1.getX(), (int) e2.getY());

        if (pos >= 0 && temp_position == pos)
            getSwipeItem(false, pos);
    } else if (e2.getX() - e1.getX() > REL_SWIPE_MIN_DISTANCE
            && Math.abs(velocityX) > REL_SWIPE_THRESHOLD_VELOCITY) {

        int pos = getListView()
                .pointToPosition((int) e1.getX(), (int) e2.getY());
        if (pos >= 0 && temp_position == pos)
            getSwipeItem(true, pos);

    }
    return false;
}
于 2013-09-05T10:06:15.533 に答える