android - onTouch 优先于 onClick [英] android - giving onTouch priority over onClick

查看:13
本文介绍了android - onTouch 优先于 onClick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个允许用户在 3 个不同视图之间滑动的活动.每个视图都显示一个图像列表.图像具有调用新活动并使图像全屏显示的 onClick 事件.这一切正常,但是如果我尝试在 3 个不同的视图之间滑动并且我的手指在图像上滑动,它将触发 onClick 事件并全屏打开图像.所以我想知道如何优先考虑 onTouch(用于页面/视图交换)?

I have an activity that allows users to swipe between 3 different views. Each view displays a list of images. The images have onClick events that call a new activity and makes the images full screen. This all works ok however if I try to swipe between the 3 different views and my finger swipes over an image it will trigger the onClick event and open the image fullscreen. So I am wondering how can I put priority on onTouch (for the page/view swapping) ?

(onTouch 事件使用了一个gestureListener,我正在使用onFling 和flipper 方法..)(onClick 只是一个 imageView.setOnClickListener(new OnClickListener() )

(the onTouch event uses a gestureListener and i'm using onFling and flipper methods..) (the onClick is simply a imageView.setOnClickListener(new OnClickListener() )

推荐答案

如果你从你的 onFling(…) 返回 true,它应该消耗事件并停止传播.

If you return true from your onFling(…) it should consume the event and stop propagation.

这篇关于android - onTouch 优先于 onClick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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