ListView and propagating click events from children views in the items

后端 未结 2 744
生来不讨喜
生来不讨喜 2021-01-22 16:03

I have a ListView with custom items - 3 ImageViews and a TextView. I have a call to setItemsCanFocus(true), so I can make the ImageViews clickable. I\'m currently u

相关标签:
2条回答
  • 2021-01-22 16:16

    Setting android:addStatesFromChildren="true" on the listview in your xml will send clicks on the child elements to the onItemClick method in the onItemClickListener connected to your listview.

    0 讨论(0)
  • 2021-01-22 16:22

    Unfortunately you have to choose between using onItemClick() or onClick() on individual children. One way to do it however is to make the top-level view of each item clickable.

    0 讨论(0)
提交回复
热议问题