Listview itemclick 不起作用 [英] Listview itemclick not work
问题描述
我的 ListView 中有一个 ListView 显示 ImageButton.
I have a ListView in my ListView show ImageButton.
我将 focusalble "false" 和 focusableInTouchMode "false" 设置为 ImageButton.
I set focusalble "false" and focusableInTouchMode "false" to ImageButton.
我设置了 ListView.OnItemClickListner.当我运行我的项目时,它会显示我的 ListView.
I set ListView.OnItemClickListner. When I run my project It's show my ListView.
但是当我点击 Listview 时它不起作用.
But When I click on Listview It's not working.
然后我删除布局中的 ImageButton 并在单击 ListView 时再次运行我的项目
Then I remove ImageButton in layout and run my project again when i click ListView It' work
怎么了?
推荐答案
android:focusable="false"
android:focusableInTouchMode="false"
不适用于 ImageButton.
doesn't work for ImageButton.
在您的布局 xml 中,将此属性添加到根布局
In your layout xml, add this property to root layout
android:descendantFocusability="blocksDescendants"
它非常适合具有 ImageButton 的列表视图.
It works perfectly for a listview that has ImageButton.
这篇关于Listview itemclick 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!