Reputation: 247
I have a android.widget.GridView and I'm setting setOnItemClickListener() on it. It works perfectly but adds a style to the UI when a cell is clicked. Any ideas how to remove this style?
Upvotes: 0
Views: 1320
Reputation: 247
Ok thanks @Sam you got me on the right track. Could not get <item android:color="#00000000" />
to work, I think for grids you need to use drawables along the lines of Android ListView Selector Color. In the end my code that works is
Java code:
mygrid.setSelector( R.color.empty_selector );
res/color/empty_selector.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/transparent"/>
</selector>
res/color/transparent.xml:
<bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="center" android:src="@drawable/transparent" />
Not sure if there had been an easier way but this has worked so I'm happy.
Upvotes: 2
Reputation: 86958
I believe you are referring to the color selector or color state list. You can probably create a dummy selector, that has no alternate values, then set it to the GridView with setSelector()
in Java or android:listSelector
in XML.
A dummy selector, it is transparent:
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:color="#00000000" />
</selector>
Upvotes: 1