java - Android 类标记为从未使用过

标签 java android android-studio

我有一个非常简单的类(ColorTool.java):

import android.graphics.Color;

public class ColorTool {

    public boolean closeMatch (int color1, int color2, int tolerance) {
        if (Math.abs (Color.red (color1) - Color.red (color2)) > tolerance ) return false;
        if (Math.abs (Color.green (color1) - Color.green (color2)) > tolerance ) return false;
        return Math.abs(Color.blue(color1) - Color.blue(color2)) <= tolerance;
    }
}

我在主类中使用它:

private final ColorTool ct = new ColorTool ();

并使用它:

int tolerance = 25;
        switch (action) {
            case MotionEvent.ACTION_DOWN :
                break;
            case MotionEvent.ACTION_UP :
                v.performClick();
                int touchColor = getHotspotColor (R.id.imgMainAreas, evX, evY);
                if(x == 1){
                    if (ct.closeMatch (Color.BLUE, touchColor, tolerance)){
                        x = 2;
                        animStart();
                    }
                }
...

无论如何,该类被标记为从未使用过,其中的函数也是如此。 (接近匹配) 当我分析应用程序的整个代码时,也会发生这种情况。 也许我会原谅一些事情? 我更新到最新的 Android Studio 版本。

最佳答案

在不同的地方可能有两个同名的类,而 Main 使用另一个类。

关于java - Android 类标记为从未使用过,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59812692/

相关文章:

java - 更改桌面背景 mac os x

java - 如何使用 ClickListener 在 Android Studio 中设置起始标记位置?

Java 设计问题 : Enforce method call sequence

android - 工具栏布局与父宽度不匹配

android-studio - 如何停止 Google Drive 创建 desktop.ini 文件

java - 如何在 Java 中对多个继承对象建模

android - Fragment 在点击时隐藏和显示

android - 在 React Native 中使用 axios 时出现网络错误

java - Android Studio 无法运行单个类

Android Studio 3.0 要求为每次启动选择设备