[英]I get an error message when I attempt to extend ImageView in Android Studio
In Android Studio I am attempting to extend the ImageView widget, but am getting the error message "there is no default constructor available in 'android.widget.ImageView'" . 在Android Studio中,我试图扩展ImageView小部件,但是收到错误消息“'android.widget.ImageView'中没有可用的默认构造函数”。 How can I resolve this error?
我该如何解决这个错误?
My code is as follows: 我的代码如下:
package com.example.trendpoints; package com.example.trendpoints;
import android.content.Context; import android.content.Context; import android.widget.ImageView;
import android.widget.ImageView;
public class CouponImageView extends ImageView { 公共类CouponImageView扩展ImageView {
public CouponImageView(Context c) {
}
} }
you just need to add super(c);
你只需要加上
super(c);
. 。 The compiler is telling that there is no available default constructor available.
编译器告诉我们没有可用的默认构造函数。 The default constructor is the one without parameters, that without
super(c)
, you are trying to call in an implicit way 默认构造函数是没有参数的构造函数,没有
super(c)
,你试图以隐式方式调用
public CouponImageView(Context c) {
super(c);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.