我是Android新手,我正在研究Gestures
。我有关于如何识别文本的问题。当用户绘制必须被识别并且必须打印在屏幕顶部的字母或数字时。我开始知道它可以通过GestureOverlayView
完成,但不知道如何实现它。
任何人都可以帮我一些示例代码。
答案 0 :(得分:3)
您可以使用这两个有用的链接
使用此
public class YourClass extends Activity implements OnGesturePerformedListener {
private GestureLibrary mLibrary;
mLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures);
if (!mLibrary.load()) {
finish();
}
GestureOverlayView gestures = (GestureOverlayView)findViewById(R.id.gestures);
gestures.addOnGesturePerformedListener(this);
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
Log.v("performed","performed");
// We want at least one prediction
if (predictions.size() > 0) {
Prediction prediction = predictions.get(0);
// We want at least some confidence in the result
if (prediction.score > 1.0) {
if(prediction.name.equalsIgnorecase("right")){
//do you thing here//
}