Custom view com/android/cricle/Circleview is missing constructor used by tools: (Context) or (Context,AttributeSet) or (Context,AttributeSet,int)(转)

当安卓中出现Custom view com/android/cricle/Circleview is missing constructor used by tools: (Context) or   (Context,AttributeSet) or (Context,AttributeSet,int)警告时,说明该文件中有个类继承自View或其子类。该类需要向其超类传递参数,形式如(Context) or (Context,AttributeSet) or (Context,AttributeSet,int)。

但是有的时候,即使已经向超类传递了一个Context类型的参数,却依然报上面这个警告。

例如我有一个继承自SurfaceView的类,其构造器如下:

public AndroidFastRenderView(Context game, Bitmap framebuffer) {  
    super(game);  
    ......  
}

但是如果我把这个构造器改成:

public AndroidFastRenderView(Context game) {  
    super(game);  
    ......  
}

然后警告就消失了。

这个应该是错误检查工具的bug吧。可以直接禁止这个警告:

@SuppressLint("ViewConstructor")  
public AndroidFastRenderView(Context game, Bitmap framebuffer) {  
    super(game);  
    ......  
}

原文地址:https://www.cnblogs.com/bianhao007/p/3499534.html