0

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?

4

2 回答 2

2

好的,谢谢@Sam,你让我走上了正确的道路。无法开始 <item android:color="#00000000" />工作,我认为对于网格,您需要沿Android ListView Selector Color的行使用可绘制对象。最后我的工作代码是

Java代码:

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>

资源/颜色/透明.xml:

<bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="center" android:src="@drawable/transparent" />

不确定是否有更简单的方法,但这很有效,所以我很高兴。

于 2012-11-14T21:36:34.080 回答
1

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>
于 2012-11-14T04:09:27.293 回答