I have some ImageButtons I want to use both on, I have already implemented onTouch
like this
addAppointment.setOnTouchListener(new MyTouchListener());
and I got this:
private final class MyTouchListener implements View.OnTouchListener {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
vID = view;
ClipData data = ClipData.newPlainText("", "");
View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
view.startDrag(data, shadowBuilder, view, 0);
return true;
} else {
return false;
}
}
}
class MyDragListener implements View.OnDragListener {
@Override
public boolean onDrag(View v, DragEvent event) {
int action = event.getAction();
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
break;
case DragEvent.ACTION_DRAG_ENTERED:
break;
case DragEvent.ACTION_DRAG_EXITED:
break;
case DragEvent.ACTION_DROP:
eventLocation = (int) event.getX();
break;
case DragEvent.ACTION_DRAG_ENDED:
if (event.getResult() == true) {
addTreatment(vID, eventLocation);
System.out.println(vID);
}else{
addTreatment(vID, 0);
}
default:
break;
}
return true;
}
}
this works flawless! but i also want to add OnClickListener because its supposed to do a different action if you just single click the button. But when i set a click listener it doesn't work at all it doesn't fire the Click at all.