Is it possible to do that? I have following code:
class MyButton : AppCompatButton {
@JvmOverloads
constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0)
: super(context, attrs, defStyleAttr) {
inflateView(attrs)
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
constructor(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int)
: super(context, attrs, defStyleAttr, defStyleRes) {
inflateView(attrs)
}
fun inflateView(attrs: AttributeSet?) {
LayoutInflater.from(context).inflate(R.layout.my_button, this, true)
}
}
The inflate function gives me this error:
I understand that AppCompatButton is not inherited from ViewGroup, but what is the correct function?