我有一些ListView
。每个列表元素是使用布局看起来像这样构成:传播触摸事件
的some_selector.xml
是寻找这样的:
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:drawable="@drawable/ic_btn_stop_pressed" />
<item android:drawable="@drawable/ic_btn_stop_default" />
</selector>
现在,当用户按下整个行中,被按压的每个的TextView被以及(没有真正按下 - 没有生成onClick事件,但是TextView根据它们的选择器改变它的背景)。任何想告诉系统不要将触摸事件从父视图传播到子视图?
尝试创建自定义的ListView,覆盖dispatchTouchEvent并调用父类方法有,但返回true,以防止传播。 – Flavio 2011-05-16 12:26:34
我在这里找到解决方案http://stackoverflow.com/questions/6741908/android-child-elements-sharing-pressed-state-with-their-parent-even-when-duplica/7235953#7235953 – aeracode 2011-10-07 22:11:16