보기에서 나는 싱글 탭과 더블 탭을 모두 감지하고 싶습니다. 그것은 나와 함께 잘 작동합니다. 싱글 탭과 더블 탭을 모두 감지 할 수 있습니다. 내 코드를 찾으십시오.안드로이드에서 더블 탭보기
@Override
public boolean onTouch(View view, MotionEvent me) {
// No dragging during animation at the moment.
// TODO: Stop animation on touch event and return to drag mode.
boolean result = true;
result = gestureDetector.onTouchEvent(me);//return the double tap events
if(result)
return false;
switch (me.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE:
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
}
private class GestureListener extends GestureDetector.SimpleOnGestureListener {
private String fileName;
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
// TODO Auto-generated method stub
return false;
}
// event when double tap occurs
@Override
public boolean onDoubleTap(MotionEvent e) {
float x = e.getX();
float y = e.getY();
if(player!=null && player.isPlaying())
{
player.stop();
}
else
{
setFileName(x);
player = new AudioPlayer(fileName);
player.play();
}
return true;
}
}
Action_UP 이벤트에서 일부 코드를 수행하고 있습니다. 따라서 두 번 탭할 때도 첫 번째 탭에서 ACTION_UP 이벤트가 호출되고 해당 코드가 실행됩니다. 나는 이런 일이 일어나지 않도록하고 싶다. 어떻게해야합니까? 사용자가 제스처를 완료했을 때만 ACTION_UP이 호출되도록하고 싶습니다. 그의 부분적인 제스쳐 직후가 아닙니다. 이 경우 첫 번째 탭을 위로 손가락으로 가리킨다.
어떻게하면 안드로이드에서이 작업을 수행 할 수 있습니까? 제스처 리스너 documentation에 따르면
덕분에
귀하의 질문에 많은 의미가 없습니다. 'MotionEvent'를 변경할 수는 없지만, 예를 들어 누를 때마다 누를 때마다 마지막 누를 때부터 시간을 계산 한 다음 그 시간에 따라 다른 작업을 수행 할 수 있습니다. – Vallentin
업데이트 된 답변을 확인하십시오. 나는 당신이'onXTap' 함수에서 잘못된 값을 반환한다고 믿고 있습니다. – gunar