I am trying to set certain items in my gridview from clickable to non clickable. So I have a gridview with a custom adapter on it and a onitemclicklistener. In my Custom adapter, I try to do the following in my getView method: (since I read about calling isEnabled..)
if(int value < 5) { //item can not be clickable
isEnabled(position);
} else {
//other things happen, but isEnabled is not called here in any case
}
//......
@Override
public boolean isEnabled(int position) {
return false;
}
The strange thing is, now every item is not clickable, although there are items where the value is > 5.. I don’t know what is causing this…
So what you’re actually doing here is overriding a built in method
isEnabled(int)and telling it to always return false. This is causing your adapter to always tell your grid that its cells should not be enabled.What you’re actually looking for is something more like
The key here is that you aren’t the one calling
isEnabled. You’re overridingisEnabled, and theGridViewis calling it automatically to determine which cells should be clickable and which should not. So you should never actually callisEnabledanywhere in your code for this purpose.