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()
...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…