如何保持一个触摸事件继续把重点放在小部件它是在开始的? [英] How do I keep a touch event keep its focus on the widget it was started in?

查看:129
本文介绍了如何保持一个触摸事件继续把重点放在小部件它是在开始的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说我有一个ListView,并在它一排是我的自定义视图。自定义视图中的用户触摸 - >自定义视图得到处理此触摸事件。用户将继续是自定义视图这里面触摸序列 - >自定义视图获取到处理这些事件太

Let's say I have a ListView, and one row in it is a custom View of mine. The user touches inside the custom view -> custom View gets to handle this touch event. User continues this touch sequence inside the are of the custom View -> custom View gets to handle those events too.

问题:当用户拖动他/她的手指自定义视图(拖动启动内部),自定义视图losts触摸事件的区域之外。但我需要这些事件也一样,我怎么能做到这一点?

Problem: When the user drags his/her finger outside the area of the custom View (the drag started inside), the custom View losts the touch events. But I need those events too, how can I achieve this?

我知道,这是可以做到:如果你把包含LisView里面一堆图像的画廊,我开始拖动图库左右,并拖我的手指画廊的区域之外,而这样做(向上移动/向下太多了),我仍然控制着画廊滚动,而不是ListView控件。

I know that this can be done: if you put a Gallery containing a bunch of images inside a LisView, and I start to drag the Gallery left-right, and drag my finger outside the area of the Gallery while doing so (moving up/downwards too much), I still control the Gallery scrolling, not the ListView.

我希望,我很清楚,没有任何人有这个问题的一些建议吗?

I hope that I was clear enough, does anyone have some tips on this problem?

推荐答案

据的这个帖子由戴安娜Hackborn 的,如果你返回true在视图中的的onTouchEvent(),以下事件自动发送一个关闭事件这一观点。

According to this post by Dianne Hackborn, if you return true to a down event in a view's onTouchEvent(), following events are sent automatically to that view.

这篇关于如何保持一个触摸事件继续把重点放在小部件它是在开始的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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