enter code here
スワイプ方向を検出する必要があります。方向を検出することはできますが、そのように右上または左上をスワイプすると。左にも同じですが、私の必要条件は、左にスワイプすると指を持ち上げることなく、同様にすべての方向に左に来るだけです。誰も私を助けることができます。大変ありがとうございました!すべての方向(左、右、上、下)でスワイプジェスチャ
@Override 公共ブールonTouchEvent(MotionEventのタッチイベント){
switch (touchevent.getAction()) {
// when user first touches the screen we get x and y coordinateyo
case MotionEvent.ACTION_DOWN: {
x1 = touchevent.getX();
y1 = touchevent.getY();
break;
}
case MotionEvent.ACTION_MOVE: {
x2 = touchevent.getX();
y2 = touchevent.getY();
float deltaX = x2 - x1;
if (Math.abs(deltaX) > MIN_DISTANCE) {
// Left to Right swipe action
if (x2 > x1) {;
Log.e("RTL", "Right to Left Swap Performed");
}
else {
Log.e("LTR", "Left to Right Swap Performed");
}
} else {
if (y2 > y1) {
Log.e("UTD", "UP to Down Swap Performed");
}
// Right to left swipe action
else {
Log.e("DTU", "Down to UP Swap Performed");
}
}
}
}
return false;
}
http://stackoverflow.com/questions/4139288/android-how-to-handle-right-to-left-swipe-gestures https://developer.android.com/training/ gestures/detector.html – cokceken
@cokceken moveは動作していますが、正確な左、右、上、下を得ることはできません – user2806221
方向を返す関数はないと思います。あなたは数学をするべきです。移動ベクトルを計算し、角度を計算します。あなたのベクトルがXより大きく、あなたの角度がZ-Yの間であれば、ユーザーはdirection1をスワイプします。 – cokceken