嗨我想在这个应用程序中创建一个应用程序用户通过拖放图像创建流程图 像电脑中的edraw软件请告诉我如何实现这一点 提前完成了
答案 0 :(得分:2)
样本:
private void dragImage() {
imgLogo.setOnLongClickListener(new
OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// ClipData data = ClipData.newPlainText("dot",
// "Dot : " + v.toString());
ClipData data = ClipData
.newPlainText("dot",
"Oops!\r\nWe are pleased that we have such clever customers! ;)");
MyDragShadowBuilder myShadow = new MyDragShadowBuilder(
v);
v.startDrag(data, myShadow, (Object) v, 0);
return false;
}
});
imgLogo.setClickable(true);
imgLogo.setFocusable(true);
imgLogo.setOnDragListener(new OnDragListener() {
@Override
public boolean onDrag(View v, DragEvent event) {
final int action = event.getAction();
// if (myShadow != null)
// myShadow.setCurrentPosition(event.getX(), event.getY());
switch (action) {
case DragEvent.ACTION_DRAG_STARTED: {
imgLogo.setVisibility(View.INVISIBLE);
}
break;
case DragEvent.ACTION_DRAG_ENDED: {
// Hide the surprise again
imgLogo.setVisibility(View.VISIBLE);
// Report the drop/no-drop result to the user
final boolean dropped = event.getResult();
// tvGalleryLblQty.setText("ended");
}
break;
case DragEvent.ACTION_DROP: {
final boolean dropped = event.getResult();
}
break;
}
return false;
}
});
}