Prevent drag drop of custom mimetype to EditText

前端 未结 4 2153
南旧
南旧 2021-02-20 02:41

I have a custom mime type which I am intending to use to drag and drop application objects within the app. This seems to be working but I\'m finding that the EditText fields ar

4条回答
  •  孤街浪徒
    2021-02-20 03:22

    Returns true if the drag event was handled successfully, or false if the drag event was not handled. Note that false will trigger the View to call its onDragEvent() handler.

    This is statement from the docs of onDrag(View v, DragEvent event). So if you return false then the event is handled by onDragEvent() of EditText. Hence the simplest solutions is:

    editText.setOnDragListener(new OnDragListener() {
    
            @Override
            public boolean onDrag(View v, DragEvent event) {
                return true;
            }
        });
    

    In case you would like to perform some functions, specify based on the Drag event and they will be executed.

提交回复
热议问题