If you want to disable items in the gridview, you need to do the following two things:
1. areallitemsenabled of override Adapter
2. isenabled (INT position) of override Adapter)
3. If you want to set the items corresponding to the gray object during disable, you only need to set the Alpha value of the corresponding view in the getview method.
For example:
class MyAdapter extends BaseAdapter { @Override public boolean isEnable(int position) { // return true for clickable , false for not return isShouldEnableItem(position); } @Override public boolean areAllItemsEnabled() { return false; } @Override public View getView(int position, View convertView, ViewGroup parent) { ... if (isEnabled(position)) { convertView.setAlpha(1f); } else { convertView.setAlpha(0.2f); } ... }}
PS: the Alpha value, 0 means the view is completely transparent and 1 means the view is completely opaque.