在 Android 中创建手势
您好,我正在关注本教程
http://www.vogella.de/articles/AndroidGestures/article .html 我想创建一个应用程序,用户可以在其中添加他的手势到我的应用程序中,然后使用它进行身份验证。我知道使用此代码我可以检查他输入的手势是否正确。
软件包 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 应用程序中添加手势的任何方法或链接。
Hi i am following this tutorial
http://www.vogella.de/articles/AndroidGestures/article.html
i want to create an application in which user can add his gesture inmy application and then use it for authentication.i know using this code i can check whether gesture entered by him is correct or not.
package de.vogella.android.gestures;
import 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();
}
}
}
}
ok but please help me that how to add in gesture in R.raw.animate file.please suggest any way or link for adding a gesture in android app .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
摘自此处:
...
这里您有手势生成器的源代码
手势生成器已安装在模拟器中,但您可以从 此处
以及手势源代码示例此处
Extracted from here :
...
Here you have the source code of Gesture Builder
Gesture builder is installed in the emulator , but you can download it from here
And gesture source code examples here
另外,您可能需要在使用之前调用gestureLib.load()
Also, you may need to call gestureLib.load() before using it
手势生成器的源代码:
https://android.googlesource.com/平台/开发/+/master/apps/GestureBuilder/
Source code of gesture builder:
https://android.googlesource.com/platform/development/+/master/apps/GestureBuilder/