android - disable Listview item click and re-enable it

老子叫甜甜 提交于 2019-12-01 15:56:38

What about having an instance variable on your adapter:

boolean ignoreDisabled = false;

Then in areAllItemsEnabled:

public boolean areAllItemsEnabled() {
    return ignoreDisabled;
}

and then at the beginning of isEnabled:

public boolean isEnabled(int position) {
    if (areAllItemsEnabled()) {
        return true;
    }
     ... rest of your current isEnabled method ...
}

Then you can switch between the two modes by setting ignoreDisabled appropriately and calling invalidate on your ListView.

Note that the addition to isEnabled is probably unneeded; it just seems a bit more complete.

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