android 사용자 정의 View 이벤트 길게 누르기
2662 단어 andorid
public boolean onTouchEvent(MotionEvent event) {
if(event.getAction()==MotionEvent.ACTION_DOWN){
Log.e("actionDown"," x="+x+" y="+y);
x= event.getX();
y=event.getY();
downTime=event.getDownTime();
}else if (event.getAction()==MotionEvent.ACTION_MOVE){
x=event.getX();
y=event.getY();
if(event.getEventTime()-downTime>1000){
Log.e("action move", " ");
postInvalidate();
}
}else if(event.getAction()==MotionEvent.ACTION_UP){
long time=event.getEventTime();
Log.e("event actionUp",time+" downTime="+event.getDownTime());
}
return true;
}