justasm / DragLinearLayout

Android LinearLayout with drag and drop to reorder.
MIT License
453 stars 121 forks source link

Add Ability to Disable View Draggability #39

Open DanStout opened 7 years ago

DanStout commented 7 years ago

It would be nice to be able to make views which are currently draggable non-draggable. Maybe like this:

Current: public void setViewDraggable(View child, View dragHandle) Possibe: public void setViewDraggable(View child, View dragHandle, boolean isDraggable)

kairliyev commented 4 years ago

Add this method in class to disable view draggability. Then u can disable, throw by for loop every view in list

public void disableViewDraggable(View child, View dragHandle){
        if (null == child || null == dragHandle) {
            throw new IllegalArgumentException(
                    "Draggable children and their drag handles must not be null.");
        }
        if (this == child.getParent()) {
            dragHandle.setOnTouchListener(null);  //set null
            draggableChildren.delete(indexOfChild(child));
        } else {
            Log.e(LOG_TAG, child + " is not a child, cannot make draggable.");
        }
}