0

I have a Gridview and I populate it with a custom adapter that extends BaseAdapter.

public class ImageAdapter extends BaseAdapter {
...
}

and I have these methods overridden to disable couple of the tiles

@Override
public boolean areAllItemsEnabled() {
    return false;
}

@Override
public boolean isEnabled(int position) {
    if (position == 1 || position == 2) {
        return false;
    }
    else
    {
        return true;
    }
}

so it disables the click on tiles in position 1 and 2.

Now, I'm fairly new to android development and I was wondering what a good way is to make the tiles greyed out. Can I specify style xml specific to disabled tiles?

Professor Chaos
  • 8,850
  • 8
  • 38
  • 54

1 Answers1

1

I tried to grey them out myself. But i have come to realize that it looks much better if you just use alpha to make them look like they arent completely there. I think this looks better because the View will look more like that Background, if the background is grey it will look greyed out, if its some other color or even a picture, the effect looks smoother. But thats subjective.

in your get View do something like

if (isEnabled(position)) {
  view.setAlpha(1f);
} else {
  view.setAlpha(0.45f);
}

if you insist on a grey color, set the view backgroundcolor to grey and it will appear to be slightly grey since you can see the background color through the view.

Daniel Bo
  • 2,518
  • 1
  • 18
  • 29