如何禁用子项的列表视图(使其颜色灰色,无法点击)使其、视图、灰色、颜色

2023-09-07 10:46:23 作者:See You Again

在我的应用程序,有一个列表视图,并点击它的每个项目导致的操作。

in my application, there is a listview, and clicking each item of it leads to an operation.

,但在某些情况下,一些操作不能进行。

but in some situation, some operation can not be done.

如何在列表视图禁用子项(使其颜色灰色,无法点击)?

how to disable a child item in a listview (make its color gray and unclickable)?

推荐答案

您应该重写isEnabled在您的适配器。只要跟踪要禁用,并返回他们的正确值的项目。

You should override isEnabled in your adapter. Just keep track of the items you want to disable and return the correct value for them.