2014-03-31 57 views
0

我创建一个Android应用程序。我在其中认识到这条线(两条垂直线都是垂直的&)。我已经使用了以下步骤。Android的手势识别 - 垂直线

1) Creating straight lines gesture file using "Gestures Builder" application. 
2) Added the "gestures" file in my application and used the "OnGesturePerformedListener" to recognize the line. 

The problem is, 
I can't recognize the vertical lines(Both Top to Bottom & Bottom to Top). 

我可以识别垂直线以外的直线。任何人都可以知道如何获得垂直线检测?

代码片段:

public class GestureActivity extends Activity implements OnGesturePerformedListener { 
    private GestureLibrary mLibrary; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    GestureOverlayView gestureOverlayView = new GestureOverlayView(this); 
    View inflate = getLayoutInflater().inflate(R.layout.activity_gesture, 
      null); 
    gestureOverlayView.addView(inflate); 
    gestureOverlayView.addOnGesturePerformedListener(this); 
    mLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures); 
    if (!mLibrary.load()) { 
     finish(); 
    } 
    setContentView(gestureOverlayView); 
} 

@Override 
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) { 
    ArrayList<Prediction> predictions = mLibrary.recognize(gesture); 
    if (predictions.size() > 0) { 
     Prediction prediction = predictions.get(0); 
     if (prediction.name.equals("Line") && prediction.score > 1.0) { 
      Toast.makeText(this, "Line", Toast.LENGTH_LONG).show(); 
     } 
    } 

} 

}

+0

在这里发表您的代码解决方案.... –

+0

请提供有关细节。 –

+0

@Md Abdul Gafur:谢谢你的回应。我已经在问题中发布了我的代码。 – SKK

回答