禁用的Andr​​oid的GridView突出完全(禁用选择)突出、Andr、oid、GridView

2023-09-05 10:39:26 作者:九阴争精

我试图禁用对象的高亮显示在GridView中的Andr​​oid 2.2。

I'm trying to disable the highlighting of objects in a GridView in Android 2.2.

我发现这对方的回答说我应该设置选择为透明ColorDrawable(安卓listSelector =@机器人:彩色/透明),但在我的GridView的意见,当我选择他们仍然暗淡

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

我只是用GridView控件显示在网格静态对象。没有这些对象将被选中。它会更好只使用一个基本观点和手动绘制我的图片?

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

推荐答案

好了,它看起来像我找到了答案。

Ok, it looks like I found the answer.

在你的适配器为GridView的定义,你将不得不重写以下方法:

In the definition of 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 cause all of the items in your grid to be non-selectable, but it will get rid of the highlight completely.