I have a drag and drop code. If the user touch the item, the OnTouchListener
Code starts:
View.OnTouchListener dragListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
// start move on a touch event
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
ClipData data = ClipData.newPlainText("", "");
View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
view.startDrag(data, shadowBuilder, view, 0);
// API 24
// view.startDragAndDrop(data, shadowBuilder, view, View.DRAG_FLAG_GLOBAL); // API 24
view.setVisibility(View.VISIBLE);
return true;
}
return false;
}
};
But I would have a OnLongClickListener
on my code. If the item was hold (long clicked) by the user, a toast messages was show on the display:
homebutton.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View arg0) {
Toast.makeText(UserArea.this, "laaaange geklickt", Toast.LENGTH_SHORT).show();
return true;
}
});
But it doesn't work :-(