android:clickable="true" mean's that it's not clickable?

I have a ListView with some custom sections in it. Each section has it's own header View. I want the elements in the list to be clickable, but obviously do not want the section headers to be clickable. So in the xml for the section headers I added android:clickable="false".

When debugging I noticed that the section headers were still responding to my setOnItemClickListener(). Then I tried setting android:clickable="true" in the XML. And sure enough, the section header views no longer respond to the clicks...

So what is the deal here? Why is it that setting clickable = true telling it that it is NOT clickable? Am I misunderstanding something here? Here is my XML:

<?xml version="1.0" encoding="utf-8"?>
<TextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/item_text"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textColor="@color/black"
    android:background="@android:color/transparent"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:paddingLeft="30dp"
    android:clickable="true" />

If I set that clickable="false" at the bottom, then this view begins to respond to the setOnItemClickListener()...


Solution 1:

When you set the OnItemClickListener, the event onItemClicked will only be called if the child of the ListView does not have the OnClickListener set. Setting clickable to true will provide the child view (in this case your TextView) with an empty OnClickListener. Since the TextView's OnClickListener is set the OnItemClickListener will not be called.

Solution 2:

I think you should not write android:clickable="true" when it was a child of the list item view. If you have a selector for the listitem, just setbackground on the root tag.