昨天在開發的時候遇到個問題,就是ListView中,setOnItemClickListener竟然不起任何作用,也就是說OnItemClickListener已經被攔截了,導致不起作用!
在百度google後,找到問題在於,我的Item當中有很多ImageView,TextView,無論是否顯示,組件都有這樣的屬性:
<pre name="code" class="java">android:clickable="true"
android:focusable="true"
android:focusableInTouchMode="true"
於是按照百度google的建議將這些定義的屬性全部修改爲false,終於可以使用了! 這個解決方案同樣適用於CheckBox和ImageButton!
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
下面附上兩篇參考鏈接:
http://gotoanswer.com/?q=Android+ListView+OnItemClickListener+event+is+not+working
http://www.cnblogs.com/xilinch/archive/2012/11/06/2756533.html 如果我說的方法不行的話,來參考這個鏈接應該可以!