gpt4 book ai didi

android - 在安卓中创建手势

转载 作者:太空宇宙 更新时间:2023-11-03 12:23:47 24 4
gpt4 key购买 nike

您好,我正在学习本教程

http://www.vogella.de/articles/AndroidGestures/article.html我想创建一个应用程序,用户可以在其中添加他的手势到我的应用程序中,然后使用它进行身份验证。我知道使用这段代码我可以检查他输入的手势是否正确。

package de.vogella.android.gestures;

导入java.util.ArrayList;

public class GestureTest extends Activity implements OnGesturePerformedListener {
private GestureLibrary gestureLib;


/** Called when the activity is first created. */

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

@Override
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
ArrayList<Prediction> predictions = gestureLib.recognize(gesture);
for (Prediction prediction : predictions) {
if (prediction.score > 1.0) {
Toast.makeText(this, prediction.name, Toast.LENGTH_SHORT)
.show();
}
}
}
}

好的,但请帮助我了解如何在 R.raw.animate 文件中添加手势。请建议在 Android 应用程序中添加手势的任何方式或链接。

最佳答案

摘自here :

Android 1.6 and higher SDK platforms include a new application pre-installed on the emulator, called Gestures Builder. You can use this application to create a set of pre-defined gestures for your own application...

...

As you can see, a gesture is always associated with a name. That name is very important because it identifies each gesture within your application. The names do not have to be unique. Actually it can be very useful to have several gestures with the same name to increase the precision of the recognition. Every time you add or edit a gesture in the Gestures Builder, a file is generated on the emulator's SD card, /sdcard/gestures. This file contains the description of all the gestures, and you will need to package it inside your application inside the resources directory, in /res/raw.

Here你有 Gesture Builder 的源代码

手势生成器安装在模拟器中,但您可以从here 下载它。

及手势源码实例here

关于android - 在安卓中创建手势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7778334/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com