Turn off Android GridView highlighting (turn off selection)

I am trying to turn off object selection in a GridView in Android 2.2.

I found this other answer , saying that I have to set the selector to transparent ColorDrawable ( android:listSelector="@android:color/transparent" ), but the views in my GridView still fade when I select them.

I just use GridView to display static objects in a grid. None of these objects will be selected. Would it be better to just use the base view and draw my images manually?

+10
android gridview selector
Jul 01 '10 at 16:50
source share
4 answers

Well, it looks like I found the answer.

In defining your adapter for the GridView, you will have to override the following methods:

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

This will make it impossible to select all the elements in your grid, but completely get rid of the selection.

+22
Jul 06 '10 at 14:17
source share

To save clickable items, you should use attr below. in your gridview xml:

Android: listSelector = "# 00000000"

See also: http : //stackoverflow.com

+36
Oct 19 2018-11-11T00:
source share

Just Set v.setOnClickListener(null);

+1
Aug 30 '10 at 19:34
source share

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

 gridview.getSelector().setAlpha(0); 
0
Jun 22 '15 at 19:03
source share



All Articles