如何onClick事件传递到其在Android父? [英] How to pass the onClick event to its parent on Android?

查看:437
本文介绍了如何onClick事件传递到其在Android父?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在卫生组织背景布局一个TextView是一个选择。而TextView的文本设置为从HTML到跨区。 然后,我设置了LinkMovementMethod TextView的。

I have a TextView in a layout whos background is a Selector. And the TextView's text is set to Spanned from HTML. Then I set the TextView with the LinkMovementMethod.

现在,当我轻点的TextView,click事件不会被发送到其父布局触发选择。

Now when I tap on the TextView, the click event is not sent to its parent layout to trigger the selector.

应如何解决? 谢谢!

推荐答案

我认为你需要使用这些方法之一,以便能够截获该事件之前,它被发送到相应的组件:

I think you need to use one of those methods in order to be able to intercept the event before it gets sent to the appropriate components:

Activity.dispatchTouchEvent(MotionEvent) - 这可以让你的活动,以拦截所有触摸事件,他们被分派到了窗口前

Activity.dispatchTouchEvent(MotionEvent) - This allows your Activity to intercept all touch events before they are dispatched to the window.

ViewGroup.onInterceptTouchEvent(MotionEvent) - 这允许的ViewGroup观看赛事,他们被分派到子视图

ViewGroup.onInterceptTouchEvent(MotionEvent) - This allows a ViewGroup to watch events as they are dispatched to child Views.

ViewParent.requestDisallowInterceptTouchEvent(布尔) - 调用此当父视图,表示它不应该拦截触摸事件与onInterceptTouchEvent(MotionEvent)

ViewParent.requestDisallowInterceptTouchEvent(boolean) - Call this upon a parent View to indicate that it should not intercept touch events with onInterceptTouchEvent(MotionEvent).

更多信息href="http://developer.android.com/guide/topics/ui/ui-events.html#EventHandlers">这里

More information here.

希望有所帮助。

这篇关于如何onClick事件传递到其在Android父?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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