Graykos
Graykos

Reputation: 1311

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?

Upvotes: 6

Views: 5682

Answers (3)

Srishti Roy
Srishti Roy

Reputation: 576

It is better to do the onlcick on listview item only.You can set some flag and toggle between the functionalities.

Upvotes: 0

Tomer Mor
Tomer Mor

Reputation: 8028

you need to set on item click like this listView.setOnItemClickListener();

Upvotes: 0

Carnal
Carnal

Reputation: 22064

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.

Upvotes: 20

Related Questions