完全禁用 Android GridView 突出显示(禁用选择) [英] Disable Android GridView highlighting completely (disable selection)

查看:27
本文介绍了完全禁用 Android GridView 突出显示(禁用选择)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Android 2.2 中禁用 GridView 中对象的突出显示.

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

我发现 另一个答案 说我应该将选择器设置为透明ColorDrawable (android:listSelector="@android:color/transparent"),但是当我选择它们时,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?

推荐答案

在为 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, and will get rid of the highlight completely.

这篇关于完全禁用 Android GridView 突出显示(禁用选择)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆