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)