0
我尝试在FAB中拖放,但我的拖放操作从未调用;拖放FloatingActionButton Android
这里是我拖累激活码:
View.OnLongClickListener onDrag = new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(v);
v.getClass();
v.startDrag(ClipData.newPlainText("test", "test"), shadowBuilder, v, 0);
return true;
}
};
这里读心人:
protected class myDragEventListener implements View.OnDragListener {
// This is the method that the system calls when it dispatches a drag event to the
// listener.
public boolean onDrag(View v, DragEvent event) {
// Defines a variable to store the action type for the incoming event
final int action = event.getAction();
switch (action) {
case DragEvent.ACTION_DRAG_ENTERED:
v.setBackgroundColor(Color.GRAY);
return true;
case DragEvent.ACTION_DRAG_EXITED:
//v.setBackgroundColor(Color.TRANSPARENT);
return true;
case DragEvent.ACTION_DRAG_STARTED:
return true;
case DragEvent.ACTION_DRAG_LOCATION:
//v.setVisibility(View.VISIBLE);
return false;
// return processDragStarted(event);
case DragEvent.ACTION_DROP:
Toast.makeText(context, "teste ok", Toast.LENGTH_SHORT).show();;
default:
return true;
}
}
,我在我的工厂设置:(setOnClickListener和setOnDragListener)