Java Code Examples for android.view.View#setOnDragListener()

The following examples show how to use android.view.View#setOnDragListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DragListenerGridView.java    From PlusDemo with Apache License 2.0 6 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);
        orderedChildren.add(child); // 初始化位置
        child.setOnLongClickListener(new OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                draggedView = v;
                v.startDrag(null, new DragShadowBuilder(v), v, 0);
                return false;
            }
        });
        child.setOnDragListener(dragListener);
    }
}
 
Example 2
Source File: ViewDragListenerView.java    From Android_UE with Apache License 2.0 6 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    int childCount = getChildCount();
    for (int index = 0; index < childCount; index++) {
        View childAt = getChildAt(index);
        mChildViews.add(childAt);
        childAt.setOnLongClickListener(new OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                mDragView = view;
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                    view.startDragAndDrop(null, new DragShadowBuilder(view), view, 0);
                }
                return false;
            }
        });
        childAt.setOnDragListener(this);
    }
}
 
Example 3
Source File: DragUtils.java    From DraggedViewPager with Apache License 2.0 4 votes vote down vote up
public static void removeDragEvent(View view) {
    view.setOnDragListener(null);
    view.setOnTouchListener(null);
    view.setOnLongClickListener(null);
}