I have a ListView that contains an imageview, a textview, and a checkbox. The rows became unclickable when I added the imageview. I have tried many solutions I found including android:focusable="false"
, android:descendantFocusability="blocksDescendants"
and android:clickable=true
.
Here is my ListView:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:clickable="true"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical" >
<ImageView
android:id="@+id/imgListView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:focusable="false"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/txtListView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/imgListView"
android:focusable="false"
android:textColor="#FFFFFF" />
<CheckBox
android:id="@+id/chkListView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:focusable="false" />
</RelativeLayout>
and here is the activity using it:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".FolderActivity" >
<ListView
android:id="@+id/lstFolders"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:dividerHeight="1dp"
android:divider="#FFFFFF">
</ListView>
</RelativeLayout>
I just need the rows to be clickable again like they were before.
PS: I alreadu had the same problem when I first added the checkbox and solved it with android:focusable="false"
.