Android Drag and Drop ACTION_DRAG_ENDED not firing

后端 未结 2 1402
伪装坚强ぢ
伪装坚强ぢ 2021-02-12 23:43

I\'m really having a time figuring this one out and can\'t find any friends with the relevant experience so far. It\'s my VERY LAST FEATURE before I release my VERY FIRST APP s

2条回答
  •  别跟我提以往
    2021-02-13 00:30

    This may be related to this issue:

    https://code.google.com/p/android/issues/detail?id=25073

    Overriding the dispatchDragEvent function as suggested at that link worked for me:

    @Override
    public boolean dispatchDragEvent(DragEvent ev){
        boolean r = super.dispatchDragEvent(ev);
        if (r && (ev.getAction() == DragEvent.ACTION_DRAG_STARTED
                || ev.getAction() == DragEvent.ACTION_DRAG_ENDED)){
            // If we got a start or end and the return value is true, our
            // onDragEvent wasn't called by ViewGroup.dispatchDragEvent
            // So we do it here.
            onDragEvent(ev);
        }
        return r;
    }
    

提交回复
热议问题