【开源】DragAndDropBTWLayouts
DragAndDropBTWLayouts
使用说明:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
// test drag and transferFrameLayout rootFrameLayout;LinearLayout topLL; LinearLayout bottomLL;DraggableLinearLayoutTouchListener mTopDraggableLinearLayoutTouchListener;DraggableLinearLayoutTouchListener mBottomDraggableLinearLayoutTouchListener;// topLL --> bottomLLmTopDraggableLinearLayoutTouchListener = new DraggableLinearLayoutTouchListener(topLL, rootFrameLayout, bottomLL, new DraggableLinearLayoutTouchListener.TransferCallbacks() { @Override public boolean canTransfer(int position) { return position != 0 && position != 1; } @Override public int transferToPosition() { return 2; } @Override public void onTransfer(LinearLayout linearLayout, LinearLayout targetLinearLayout, int position, int toPosition) { if (toPosition < targetLinearLayout.getChildCount()) { View view = targetLinearLayout.getChildAt(toPosition); view.setBackgroundResource(R.drawable.condition_invalid_bg); } } @Override public void onClick(LinearLayout linearLayout, View view, int position) { if (position == 0) { if (linearLayout.getChildCount() > 2) { mTopDraggableLinearLayoutTouchListener.doTransferOnSimpleClick(linearLayout.getChildAt(2), 2); } } } }); topLL.setOnTouchListener(mTopDraggableLinearLayoutTouchListener); // bottomLL --> topLL mBottomDraggableLinearLayoutTouchListener = new DraggableLinearLayoutTouchListener(bottomLL, rootFrameLayout, topLL, new DraggableLinearLayoutTouchListener.TransferCallbacks() { @Override public boolean canTransfer(int position) { return position != 0 && position != 1; } @Override public int transferToPosition() { return 2; } @Override public void onTransfer(LinearLayout linearLayout, LinearLayout targetLinearLayout, int position, int toPosition) { if (toPosition < targetLinearLayout.getChildCount()) { View view = targetLinearLayout.getChildAt(toPosition); view.setBackgroundResource(R.drawable.condition_valid_bg); } } @Override public void onClick(LinearLayout linearLayout, View view, int position) { if (position == 0) { if (linearLayout.getChildCount() > 2) { mBottomDraggableLinearLayoutTouchListener.doTransferOnSimpleClick(linearLayout.getChildAt(2), 2); } } } }); bottomLL.setOnTouchListener(mBottomDraggableLinearLayoutTouchListener);
|
posted on 2015-04-03 10:39 wasdchenhao 阅读(100) 评论(0) 收藏 举报

浙公网安备 33010602011771号