Skip to content Skip to sidebar Skip to footer

Disable Android Gridview Highlighting Completely (disable Selection)

I'm trying to disable the highlighting of objects in a GridView in Android 2.2. I found this other answer saying that I should set the selector to a transparent ColorDrawable (andr

Solution 1:

For keeping the items clickable you should use below attr. in your GridView xml:

android:listSelector="#00000000"

See also: https://stackoverflow.com/a/2866074/928591

Solution 2:

In the definition of your Adapter for the GridView, you will have to override the following methods:

@OverridepublicbooleanareAllItemsEnabled()
{
    returnfalse;
}

@OverridepublicbooleanisEnabled(int position)
{
    returnfalse;
}

This will cause all of the items in your grid to be non-selectable, and will get rid of the highlight completely.

Solution 3:

Just Set v.setOnClickListener(null);

Solution 4:

If you just want to disable the visual aspect of the selection, you can do the following:

gridview.getSelector().setAlpha(0);

Post a Comment for "Disable Android Gridview Highlighting Completely (disable Selection)"