Android開發(fā)中在ListView中經(jīng)常有Button或ImageButton等需要被點(diǎn)擊的控件,如果不加一些特殊的限制,有可能ListView的Item的點(diǎn)擊事件或Button的點(diǎn)擊事件,其中一個(gè)不能響應(yīng)。我遇到的情況是ListView的Item不能響應(yīng)點(diǎn)擊事件。 解決的辦法,在ListView的Item的xml文件中添加如下屬性: 1)整個(gè)xml文件的根元素如LinearLayout中添加屬性android:descendantFocusability="blocksDescendants" 2)被點(diǎn)擊的控件如ImageButton中添加屬性android:focusable="false"和android:clickable="true" 完美解決!
|
|