Non-clickable Listview Item with Visible Divider

烈酒焚心 提交于 2019-12-05 21:57:28

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.

All items will not be clickable since areAllItemsEnabled() == false but the divider will appear.

I also had this issue, but overwriting these Adapter methods seemed ugly. Then one post struck me with an idea, that had worked before already. On the view that shouldn't be clickable just call view.setOnClickListener(null).

Boom, maybe this is a workaround rather than a real solution, but it works. I have to note that I added dividers programmatically to the ListView footer, so I had the reference to the dividers and I could simply set the OnClickListener to null.

On the individual View, trying setting it to not be clickable: view.setClickable(false). If that doesn't work, try view.setFocusable(false).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!