Amit Sharma
Amit Sharma

Reputation: 936

ListView Touch is disabled with button

**I am using custom listview when i placing the button in custome view it is disabling the item touch or itemlongpress listener ...

How to use button click and listview touch simultaneously

Upvotes: 1

Views: 1117

Answers (2)

Brijesh Thakur
Brijesh Thakur

Reputation: 6788

The Problem here is , Listview having button as a child, Button will take the priority of onClick. Do the following thing

  • Set the property of Button to setFocusable(false);It will enable the OnClick on ListView.

  • For Click on Button - use onTouch instead of onClick. Which will allow you to click on button as well

Upvotes: 3

Riki
Riki

Reputation: 2802

try to add

android:descendantFocusability="blocksDescendants"

in the ListView tag where you define it in xml.

Upvotes: 0

Related Questions