是否可以在xml中为SurfaceView设置OnTouch事件? [英] Is this possible to set OnTouch event for SurfaceView in xml ?

查看:202
本文介绍了是否可以在xml中为SurfaceView设置OnTouch事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Buttons有一个很棒的功能,允许直接在xml中设置OnClick attribure,当我在布局之间切换时,它可以很好地工作。如果可能的话,我会为SurfaceView寻找相同的东西。为什么? - 因为当我切换到另一个布局并向后移动时触摸事件不起作用。谢谢。

There is a great feature for Buttons that allows to set OnClick attribure write directly in xml that works perfectly when I switch between layouts. I look for the same for SurfaceView if its possible at all. Why? - Because touch events not works when I switch to another layout and move back. Thanks.

推荐答案

也许你可以使用mouseup事件。行为几乎相同,并支持你描述的功能。



希望这会有所帮助......
maybe yout can use the mouseup event. the behaviour is nearly the same and supports the feature you discribe.

hope this helps...


SurfaceView [ ^ ]没有 - 但它扩展查看 [ ^ ],它有一些非常有趣的绘图和事件处理方法(键和触摸屏)。

也许你可以找到一个钩子。请阅读文档,它非常好。
SurfaceView[^] does not have that - but it extends View[^], which has some pretty interesting methods for drawing and event processing (keys and touchscreen).
Maybe you can find a hook there. Please read in the documentation, it''s pretty good.


这篇关于是否可以在xml中为SurfaceView设置OnTouch事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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