スワイプの機能を実装するためにアンドロイドプロジェクトをやっています。 これを行う方法。アンドロイドでスワイプ
オンフリン方式で試していますが、それは私にとってはうまくいきません。誰にでも正しい解決策があります。
マイonflingコードは
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (mGesturesEnabled) {
try {
if (e2.getY() - e1.getY() > StudyOptions.sSwipeMinDistance && Math.abs(velocityY) > StudyOptions.sSwipeThresholdVelocity && Math.abs(e1.getX() - e2.getX()) < StudyOptions.sSwipeMaxOffPath && !mIsYScrolling) {
// down
executeCommand(mGestureSwipeDown);
} else if (e1.getY() - e2.getY() > StudyOptions.sSwipeMinDistance && Math.abs(velocityY) > StudyOptions.sSwipeThresholdVelocity && Math.abs(e1.getX() - e2.getX()) < StudyOptions.sSwipeMaxOffPath && !mIsYScrolling) {
// up
executeCommand(mGestureSwipeUp);
} else if (e2.getX() - e1.getX() > StudyOptions.sSwipeMinDistance && Math.abs(velocityX) > StudyOptions.sSwipeThresholdVelocity && Math.abs(e1.getY() - e2.getY()) < StudyOptions.sSwipeMaxOffPath && !mIsXScrolling && !mIsSelecting) {
// right
executeCommand(mGestureSwipeRight);
} else if (e1.getX() - e2.getX() > StudyOptions.sSwipeMinDistance && Math.abs(velocityX) > StudyOptions.sSwipeThresholdVelocity && Math.abs(e1.getY() - e2.getY()) < StudyOptions.sSwipeMaxOffPath && !mIsXScrolling && !mIsSelecting) {
// left
executeCommand(mGestureSwipeLeft);
}
mIsXScrolling = false;
mIsYScrolling = false;
} catch (Exception e) {
Log.e(AnkiDroidApp.TAG, "onFling Exception = " + e.getMessage());
}
}
return false;
}
次回はフォーマットボタンを使用してフォーマットしてください。私はあなたのためにそれを体系化しましたが、それはまだインデントのいくつかの調整が必要です。また、「うまくいかない」という意味を付け加えてください。これは何をするのですか、何をやろうとしているのですか(そして理由は何か)、あなたのログは何を言いますか。もう少し努力すれば、これに簡単に答えることができます – Nanne