在创建Android的手势 [英] Creating Gestures in android

查看:201
本文介绍了在创建Android的手势的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我下面这个教程

http://www.vogella.de/articles/AndroidGestures/article.html
我想创造一个用户可以添加自己的姿态inmy应用程序,然后用它来authentication.i知道使用这种code我可以检查他的手势输入是否正确与否的应用程序。

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.

包de.vogella.android.gestures;

package de.vogella.android.gestures;

进口的java.util.ArrayList;

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();
            }
        }
    }
}

确定,但请帮助我,如何在姿态加入R.raw.animate file.please提出任何方式或链接,在Android应用中加入一个手势。

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 .

推荐答案

的:

Android 1.6及更高的SDK平台包括一个新的应用
  pre-安装在模拟器上,称为手势生成器。您可以使用
  这个应用程序来创建一组pre定义手势为自己
  应用
...

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...

...

正如你所看到的,一个手势总是与一个名字相关联。那名
  是非常重要的,因为它确定了在每个手势的
  应用。名不必是唯一的。实际上它可以是
  有几个手势具有相同的名称,以增加非常有用
  识别的precision。 每次添加或编辑手势
  在举手投足生成器,是在模拟器上的SD生成的文件
  卡/ SD卡/手势。此文件包含的所有说明
  手势,你需要将它打包你的应用程序中
  资源目录中,在/ RES /原料

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.

这里你有手势生成器的源$ C ​​$ C

Here you have the source code of Gesture Builder

手势生成器安装在仿真的,但你可以从<一个下载href=\"http://$c$c.google.com/p/quickdroid/downloads/detail?name=com.android.gesture.builder.apk\">here

Gesture builder is installed in the emulator , but you can download it from here

和手势源$ C ​​$ C例子<一个href=\"http://$c$c.google.com/p/apps-for-android/downloads/detail?name=GesturesDemos.zip&can=2&q=#makechanges\">here

And gesture source code examples here

这篇关于在创建Android的手势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆