2


I've got some ListView. Each list element is constructed using layout looking like this:

<SomeRootLayout android:background="@layout/some_other_selector">
    <TextView android:background="@layout/some_selector"/>
    <TextView android:background="@layout/some_selector"/>
    <ImageView/>
</SomeRootLayout>

The some_selector.xml is looking like this:

<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>

Now, when the user press the entire row, the each TextView is being pressed as well (not really pressed - no onClick events are generated, however TextViews change its background according to their selectors). Any ideas to tell system NOT to propagate touch events from parent to child views?

Kocus
  • 1,613
  • 17
  • 31
  • try to create custom ListView, override dispatchTouchEvent and invoke super method there but return true to prevent propagating. – Flavio May 16 '11 at 12:26
  • I found solution here http://stackoverflow.com/questions/6741908/android-child-elements-sharing-pressed-state-with-their-parent-even-when-duplica/7235953#7235953 – æ-ra-code Oct 07 '11 at 22:11

1 Answers1

2

You can set android:duplicateParentState="false" on your textview

Chris.D
  • 1,516
  • 13
  • 19