【发布时间】:2011-09-09 19:37:03
【问题描述】:
我是 Android 新手,我正在研究Gestures。我对如何识别文本有疑问。当用户绘制一个必须被识别并且必须打印在屏幕顶部的字母或数字时。我知道可以通过GestureOverlayView完成,但不知道如何实现。
谁能帮我提供一些示例代码。
【问题讨论】:
标签: android gesture-recognition gestures
我是 Android 新手,我正在研究Gestures。我对如何识别文本有疑问。当用户绘制一个必须被识别并且必须打印在屏幕顶部的字母或数字时。我知道可以通过GestureOverlayView完成,但不知道如何实现。
谁能帮我提供一些示例代码。
【问题讨论】:
标签: android gesture-recognition gestures
这两个链接对你有帮助
使用这个
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//
}
【讨论】: