Skip to content Skip to sidebar Skip to footer

How To Disable Grid Item When Activity Is Loaded

I have few grid items. Depending on the flag, I want to disable some grid items For example: Grid items are Order,CallLost,Payment. If boolean status = true, then I want to disabl

Solution 1:

I'm assuming that when you say "disable" you intend to make the grid item un-clickable (but still visible) -- as in View.setEnabled().

Try this in the RetailerImageAdapter.getView(), just before the return;

if (isDefault && position == 2) {
    v.setEnabled(false);
} else if (!default) {
    if (position == 0 | position == 1 | position == 3) {
        v.setEnabled(false);         
    }
}

I'm not positive this will work (I have not tested it), but it theoretically should.

Solution 2:

put below code before return view in getView() method in RetailerImageAdapter class

if(isDefault){
v.setClickable(true);
} else{
v.setClickable(false);
}
return v;

Note: check vice versa depending on your condition

Post a Comment for "How To Disable Grid Item When Activity Is Loaded"