【发布时间】:2021-07-09 05:31:45
【问题描述】:
有一个扩展 AppCompatImageView 的自定义 Imageview 类
显示错误:没有主构造函数就无法初始化超类型
class ImageViewVasl : AppCompatImageView() {
constructor(context: Context) : super(context) {
initialize(context = context, attrs = null)
}
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
initialize(context = context, attrs = attrs)
}
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
) {
initialize(context = context, attrs = attrs)
}
private fun initialize(
context: Context?,
attrs: AttributeSet?
) {
}
}
【问题讨论】:
标签: android kotlin android-custom-view