2

OnGestureListener在课堂上使用。我想知道我做的手势是顺时针还是逆时针,并想对这些手势执行不同的任务。是否OnGestureListener提供此功能?我怎样才能做到这一点?

4

2 回答 2

0

看看这个例子是否对你有任何帮助!

http://mobile.tutsplus.com/tutorials/android/android-sdk-creating-a-rotating-dialer/

于 2013-01-07T12:49:46.857 回答
0
 if(prediction.size() > 0){
  String gesturePerformed = prediction.get(0).name;
  if(gesturePerformed.equals("up")){
   myForeground.canvasUp();
   Toast.makeText(MyGameActivity.this,
     "up", Toast.LENGTH_LONG).show();
  }else if(gesturePerformed.equals("down")){
   myForeground.canvasDown();
   Toast.makeText(MyGameActivity.this,
     "down", Toast.LENGTH_LONG).show();
  }else if(gesturePerformed.equals("left")){
   myForeground.canvasLeft();
   Toast.makeText(MyGameActivity.this,
     "left", Toast.LENGTH_LONG).show();
  }else if(gesturePerformed.equals("right")){
   myForeground.canvasRight();
   Toast.makeText(MyGameActivity.this,
     "right", Toast.LENGTH_LONG).show();
  }else if(gesturePerformed.equals("clockwise")){
   myForeground.canvasClockwise();
   Toast.makeText(MyGameActivity.this,
     "clockwise", Toast.LENGTH_LONG).show();
  }else if(gesturePerformed.equals("anti-clockwise")){
   myForeground.canvasAntiClockwise();
   Toast.makeText(MyGameActivity.this,
     "anti-clockwise", Toast.LENGTH_LONG).show();
  }else if(gesturePerformed.equals("enlarge")){
   myForeground.canvasEnlarge();
   Toast.makeText(MyGameActivity.this,
     "enlarge", Toast.LENGTH_LONG).show();
  }else if(gesturePerformed.equals("reduce")){
   myForeground.canvasReduce();
   Toast.makeText(MyGameActivity.this,
     "reduce", Toast.LENGTH_LONG).show();
  }
 }

}

来源:http://android-coding.blogspot.in/2012/03/gestures-detection-and-canvas-scale.html

于 2013-01-07T12:52:44.197 回答