ListView中各组件点击事件冲突,ListView不响应OnItemClickListener事件

参考博文:https://xjaphx.wordpress.com/2011/07/14/listview-doesnt-respond-to-onitemclicklistener/

#1,listview item中包含checkbox,需要改变checkbox的属性设置:

android:focusable="false"
android:focusableInTouchMode="false"

#2,包含ImageButton,在代码中设置:在布局文件中设置无效

ImageButton button = (ImageButton) convertView.findViewById(R.id.imageButton);
button.setFocusable(false);

#3,TextView超链接:我擦我受不了了,原博主太萌了,我要把ta的答案直接贴过来:

4. Scenario: list item contain TextView

ProblemOnItemClickListener just doesn’t repond.

Reason: I think you have set this attribute to TextView: android:inputType=”textMultiLine”

Solution: just remove that attribute, using android:minLines/android:maxLines instead.

5. Scenario: list item contain a TextView that is linked to website URL or whatever “mailto:” things

ProblemOnItemClickListener just doesn’t repond.

Reason: the TextView overrides focus of list item.

Solution: just remove attribute “android:autoLink” on TextView.

原文地址:https://www.cnblogs.com/mada0/p/4887533.html