0
我实现像洙的onDragListener模拟一个onDragListener ....你如何在模拟器
private final class MyDragListener implements OnDragListener {
@Override
public boolean onDrag(View v, DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
System.out.println("STARTED");
break;
case DragEvent.ACTION_DRAG_ENTERED:
System.out.println("ENTERED");
break;
case DragEvent.ACTION_DRAG_EXITED:
System.out.println("EXITED");
break;
case DragEvent.ACTION_DROP:
System.out.println("DROP");
myOnClickListener.onClick(v);
break;
case DragEvent.ACTION_DRAG_ENDED:
System.out.println("ENDED");
break;
}
return true;
}
}
,并设置它像这样
for (int i = 0; i < 64; i++) {
boardLayout.getChildAt(i).setOnDragListener(myDragListener);
}
注boardLayout是一个8×8 网格布局
当我点击或拖动或任何东西,什么都不会发生在模拟器中,任何想法,为什么?
当我做在onClickListener一切完美,所以我有理由相信,模拟器犯规知道,我想也许拖...
是的,我知道,这就是问题所在,正在打印什么。 – Ogen
请不要使用的System.out.println。阅读这里:http://stackoverflow.com/questions/18393888/why-shouldnt-i-use-system-out-println-in-android –
我不使用它的时候,我用的日志,但我只需要快速测试这个 – Ogen