ListView items are not clickable. why?
Android doesn't allow to select list items that have focusable elements (buttons). Modify the button's xml attribute to:
android:focusable="false"
It should still be clickable, just won't gain focus...
I had the same issue with a ListView which contained only a RadioButton:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/userNameRadioButton"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
I used the RadioButton in each row to display the default item selection, to make ListView handle clicks I had to use:
radioButton.setFocusableInTouchMode(false);
radioButton.setFocusable(false);
or in the XML-file:
android:focusable="false"
android:focusableInTouchMode="false"
So it is a focus related issue... With the above modifiers the focus is directed to ListView on click.
This answer here worked for me: https://stackoverflow.com/a/16536355/5112161
Mainly he ADDED in the LinearLayout or RelativeLayout the following:
android:descendantFocusability="blocksDescendants"
You also need to REMOVE from all your xml the following:
android:focusable="false"
android:focusable="true"
android:clickable="true"
android:clickable="false"
I wanted to add a comment to rupps answer, but I do not have enough reputation.
If you are using a custom adapter extending the ArrayAdapter you can overwrite with areAllItemsEnabled() and isEnabled(int position) in your class:
@Override
public boolean areAllItemsEnabled() {
return true;
}
@Override
public boolean isEnabled(int position) {
return true;
}
The above fixed my non clickable list view. Maybe this comment also helps others as "android list not clickable" search term is quite high in Google.
Consider making the text value selectable by specifying android:textIsSelectable="true"
Don't listen to Google. In the rows' layout, set
textIsSelectable="false"
Thank you Lint (not!)