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
public boolean isEnabled(int position)
{
if(position < 5)
return false;
else
return true;
}
The key here is that you aren't the one calling isEnabled
. You're overriding isEnabled
, and the GridView
is calling it automatically to determine which cells should be clickable and which should not. So you should never actually call isEnabled
anywhere in your code for this purpose.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With