用手势开始新活动

问题描述:

好的。所以我一直在看手势等,并试图找出如何设置我的代码,以便当像左滑动一样的事情发生时,我可以打开一个新的屏幕,并与右刷卡相同。像日历一样,你可以在那里滑过日子。我已经建立了手势。谢谢您的帮助。用手势开始新活动

好的。我想我想出了一些东西。我现在无法完全尝试,但看起来是否正确?谢谢。

public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) { 
     ArrayList<Prediction> predictions = mLibrary.recognize(gesture); 
     if (predictions.size() > 0 && predictions.get(0).score > 1.0) { 
      String action = predictions.get(0).name; 

      if ("left".equals(action)) { 
       Intent intent = new Intent(Actinium.this, Radium.class); 
       startActivity(intent); 
       finish();} 
      else if ("right".equals(action)) { 
       Intent intent = new Intent(Actinium.this, Thorium.class); 
       startActivity(intent); 
       finish();} 

      } 
     } 

Intent intent = new Intent(this, MyActivity.class); 
startActivity(intent); 

请参阅documentation听手势。

+0

我已经看到了。我怎么知道像左滑动开始那个意图呢?就像它如何说明差异和开始哪项活动? – 2010-12-07 00:12:14

+1

您应该在意图中包含上下文。 Intent intent = new Intent(CurrentClass.this,MyActivity.class); – blindstuff 2010-12-07 00:13:34