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

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

Posted by: admin May 14, 2020 Leave a comment

Questions:

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.

How to&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.

Answer:

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.