Reputation:
hi i want to make a application in this app user create flow chart through drag and drop images like edraw software in computer please tell me how to implement this Thans in advance
Upvotes: 2
Views: 385
Reputation: 23000
A sample:
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;
}
});
}
Upvotes: 2