带有可见分隔线的不可点击的列表视图项 [英] Non-clickable Listview Item with Visible Divider
问题描述
我想禁止单击Listview项.一种解决方案是重写areAllItemsEnabled()
以始终返回false,而isEnabled()
则针对特定位置返回false.但是,这会导致特定Listview项周围的分隔线消失.一些人建议为areAllItemsEnabled()
返回true,为isEnabled()
返回false,但这对我不起作用.我不愿意手动放置分隔线,因为我需要在项目XML中添加父级布局.
I would like to disable clicking of a Listview item. One solution is to override areAllItemsEnabled()
to always return false, and isEnabled()
to return false for a particular position. However, this causes the divider lines around the particular Listview item to disappear. A few people suggested returning true for areAllItemsEnabled()
and false for isEnabled()
, but this is not working for me. I am hesitant to place a divider line in manually because I would need to add a parent layout to the item XML.
有没有一种方法可以将Listview项设置为不可点击并仍然保留
Is there a way to set a Listview item to be non-clickable and still retain
推荐答案
该解决方案与您被告知要做的完全相反.
您应该在areAllItemsEnabled()
中返回false,然后删除对isEnabled()
的覆盖.
它非常适合我,昨天我也在这个问题上苦苦挣扎.
The solution is exactly the opposite of what you were told to do.
You should return false in areAllItemsEnabled()
and just delete your override of isEnabled()
.
It works perfectly for me and I was also struggling with that issue yesterday.
自areAllItemsEnabled() == false
以来,所有项目均不可单击,但将显示分隔线.
All items will not be clickable since areAllItemsEnabled() == false
but the divider will appear.
这篇关于带有可见分隔线的不可点击的列表视图项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!