If I ‘click’, it will print “click”. However, once I ‘long click’ it will only print “long click”, regardless of the length.
LinearLayout ll = new LinearLayout(this);
ll.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v)
System.out.println("click");
}
});
ll.setOnLongClickListener(new OnLongClickListener(){
@Override
public boolean onLongClick(View v) {
v.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
System.out.println("long click");
case MotionEvent.ACTION_MOVE:
case MotionEvent.ACTION_UP:
}
return false;
}
});
return true;
}
});
How about just an TouchListener? It will record the time on
ACTION_DOWNand if theACTION_UPtime is long enough pull the coordinates from the MotionEvent.