I have a menu icon in my application. When I drag and drop something on it, it will show a popup. I need to extend my drag and drop to this PopupWindow
.
I am doing this as below.
Created a PopupWindow as shown
View popupView = View.inflate(anchorView.getContext(), R.layout.layout_popup, null);
PopupWindow popUpWindow = new PopupWindow(popupView, WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT);
And setting the dragListener as shown
popupView.setOnDragListener(new OnDragListener() {
@Override
public boolean onDrag(View view, DragEvent dragEvent) {
switch (dragEvent.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
Log.d("Drag", "ACTION_DRAG_STARTED");
break;
case DragEvent.ACTION_DRAG_ENDED:
Log.d("Drag", "ACTION_DRAG_ENDED");
break;
case DragEvent.ACTION_DRAG_ENTERED:
Log.d("Drag", "ACTION_DRAG_ENTERED");
break;
case DragEvent.ACTION_DRAG_EXITED:
Log.d("Drag", "ACTION_DRAG_EXITED");
break;
case DragEvent.ACTION_DROP:
Log.d("Drag", "ACTION_DROP");
break;
default:
break;
}
return true;
}
});
Below video shows what I want to achieve.
But the popupView is not responding to any drag events. I also tried using the DialogFragment
, but it didn't help either.
Any help is appreciated.
Thanks in advance.