Android: Disable highlighting in GridView

How can I turn off the orange highlight when clicking an item in a GridView?

I haven't been able to find a solution in the documentation or through testing.


Solution 1:

Use android:listSelector="#00000000" in your GridView element in your XML layout file.

Solution 2:

Another option is to reference the transparent color via @android:color/transparent

<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/grid"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:listSelector="@android:color/transparent"
/>

Solution 3:

I did the same thing in code using

GridView.setSelector(new ColorDrawable(Color.TRANSPARENT));