OnItemCLickListener not working in listview
I just found a solution from here, but by deep clicking.
If any row item of list contains focusable or clickable view then OnItemClickListener
won't work.
The row item must have a param like android:descendantFocusability = "blocksDescendants"
.
Here you can see an example of how your list item should look like.Your list item xml should be...row_item.xml
(your_xml_file.xml
)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:baselineAligned="false" android:descendantFocusability="blocksDescendants" android:gravity="center_vertical" > // your other widgets here</LinearLayout>
For my lists, my rows have other things that can be clicked, like buttons, so doing a blanket blocksDescendants doesn't work. Instead I add a line in the button's xml:
android:focusable="false"
That keeps the buttons from blocking the clicks on the rows, but still lets the buttons take the clicks, too.