Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do Button click and list view item click in customize list view in android

Tags:

android

I have 4 items in my list view in these 3 are text view and one is button in my case i have to open 2 new activities from a single list

1st from on button click 2nd from on list view item click

but when i add the button in list view list click is not working, also i am not able to handle the click of button.

I am using BaseAdapter class to set the data in list view.

Please help me to solve this.

Thanks.

like image 282
Ujjwal Bansal Avatar asked Oct 14 '11 06:10

Ujjwal Bansal


2 Answers

Or you can just set to you button

android:focusable="false"

In this case you ListView will fire onItemClick action to listener, and the Button will also work when it clicked.

like image 81
Dmitry Nelepov Avatar answered Oct 06 '22 16:10

Dmitry Nelepov


The previous answers to this didn't worked for me.

Add to your row's root layot android:descendantFocusability="blocksDescendants", this really does the trick, the buttons keep working and the list keeps firing the event.

like image 42
Gusman Avatar answered Oct 06 '22 15:10

Gusman