Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button onClick and ListView onItemClick

I got a ListView and I populate it with the view containing buttons. I set onClick listeners to the buttons from the adapted, but when I click the concrete item of the ListView - nothing happens. So, we can say only buttons onClick Listener is called, when I need listViewItem to be clicked. What to do?

like image 379
Graykos Avatar asked Sep 03 '12 12:09

Graykos


1 Answers

Set to your button in xml file: android:focusable="false"

This is because your Button takes focus. So now you can use both onClick for your buttons, and onItemClick for each row in ListView, by telling it that Button should not be focusable.

like image 189
Carnal Avatar answered Sep 20 '22 19:09

Carnal