J'essaie de détecter les gestes onFling
en étendant SimpleOnGestureListener
. J'ai aussi vérifié du code sur le web pour savoir ce qui me manquait mais je n'ai pas remarqué de différence. Le problème est avec les travaux onFling
, onDown
. S'il vous plaît laissez-moi savoir ce que je manque.Pourquoi les gestes Fling ne sont pas détectés
Code_Java:
private boolean setTouchableInfoDialog(LinearLayout infoReportContainer) {
// TODO Auto-generated method stub
Log.i(TAG, "@setTouchableInfoDialog(): Inside setTouchableInfoDialog()");
if (infoReportContainer == null) {
Log.i(TAG, "@setTouchableInfoDialog(): LinearLayout infoReportContainer Is NULL");
return false;
}else {
final GestureDetector mGestiredetector = new GestureDetector(getApplicationContext(), new mSwipeGestureDetector());
infoReportContainer.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
Log.i(TAG, "@setTouchableInfoDialog()->onTouch(): Binding the LinearLayout infoReportContainer"
+ " To the GestureDetector");
return mGestiredetector.onTouchEvent(event);
}
});
}
return true;
}
class mSwipeGestureDetector extends SimpleOnGestureListener {
private static final int SWIPE_MIN_DISTANCE = 120;
private static final int SWIPE_THRESHOLD_VELOCITY = 150;
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
// TODO Auto-generated method stub
//Added Upon Update
Log.i(TAG, "@onFling(): Fling Gesture Detected");
try {
if (e1.getY() - e2.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {
Log.i("@onFling(): ", "UpToDown Swipe");
return true;
}else if (e2.getY() - e1.getY() > SWIPE_MIN_DISTANCE && Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {
Log.i("@onFling(): ", "DownToUp Swipe");
return true;
}
}catch (Exception e){
}
//return super.onFling(e1, e2, velocityX, velocityY);
return false;
}
ajouter quelques bûches dans onFling – pskink
@pskink s'il vous plaît Scrol le code vers le bas, je pense que vous n'avez pas vu le corps onFling(), il y a quelques journaux. c'est ça que tu veux dire? – user2121
ajouter des journaux qui sont toujours exécutés, pas dans certaines instructions if – pskink