我有一个非常简单的类(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/