在 Android 应用程序中实现手势识别
我正在向我的应用程序添加手势识别。我已经添加了 Android 开发人员手势文章中描述的视图,但是当涉及到添加时:
mLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures);
if(!mLibrary.load()){
finish();
}
我应该将其放在代码中的什么位置,我是否必须为它创建一个新类,或者我可以将它放在内部类中,或者根本不需要上课?!我有一个类似于月球着陆器的设置,它由两个文件组成,其中一个是一个处理游戏的几乎所有物理和绘图的线程。另一个文件开始线程和 saveInstanceState 方法。
另外,mLibrary是什么类型?!我到处都找不到!!
我想我会将 OnGesturePerformed 方法放在我的线程中,因为这是我处理所有 keyUp 和 Down 事件的地方。
I am adding gesture recognition to my app. I have added the view as described in the Android Developers Gestures article but when it comes to adding:
mLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures);
if(!mLibrary.load()){
finish();
}
where do I put this in my code, do I have to create a new class for it, or can I have it in an inner class, or does it not need a class at all?! I have a set up similar to Lunar Lander which comprises of two files, one of which is a thread that handles pretty much all the physics and drawing of the game. The other file begins the thread and saveInstanceState method.
Furthermore, what type is mLibrary?! I cannot find out anywhere!!
I imagine I will put the OnGesturePerformed method in my thread as this is where I handle all keyUp and Down events.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
阅读这篇文章:http://developer.android.com/design/patterns/gestures。 html。
在那段代码之后,您可以看到您必须实现一个侦听器。
如需完整示例,请下载此。
http ://code.google.com/p/apps-for-android/downloads/detail?name=GesturesDemos.zip&can=2&q=#makechanges
Read this article: http://developer.android.com/design/patterns/gestures.html.
After that piece of code you can see that you have to implement a listener.
For a complete example download this.
http://code.google.com/p/apps-for-android/downloads/detail?name=GesturesDemos.zip&can=2&q=#makechanges