我有一个实现 OnDragListener 的类。我需要检查在视图中放置了哪个图像。请指导我如何做到这一点。
private class ChoiceDragListener implements OnDragListener {
@Override
public boolean onDrag(View v, DragEvent event) {
switch (event.getAction()) {
case DragEvent.ACTION_DROP:
View view = (View) event.getLocalState();
view.setVisibility(View.INVISIBLE);
ImageView dropTarget = (ImageView) v;
ImageView dropped = (ImageView) view;
dropTarget.setImageDrawable(dropped.getDrawable());
break;
case DragEvent.ACTION_DRAG_ENDED:
//no action necessary
break;
default:
break;
}
return true;
}
}