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

The following examples show how to use android.view.View#setOnDragListener() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: PlusDemo   File: DragListenerGridView.java    License: 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 Project: Android_UE   File: ViewDragListenerView.java    License: 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 Project: DraggedViewPager   File: DragUtils.java    License: 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);
}