I have a ListView
that uses a customized adapter, but I can\'t click on the ListView Item ..
Activity for list view ..
package com.adham
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.
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!)
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...
set android:clickable="false" android:focusable="fasle"
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"