Reputation: 1432
// FooButton.kt
class FooButton : AppCompatButton {
@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0)
: super(context, attrs, defStyleAttr)
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int)
: super(context, attrs, defStyleAttr, defStyleRes) // Nope
}
Everything's fine when subclassing AppCompatTextView but not AppCompatButton, even though
both inherit View
's signature so subclasses can have their own base styles. Which is exactly what I'm trying to do.
I get an error at the Lollipop constructor's super
call that no functions can be called with the arguments supplied. AppCompatButton
! What makes you so special?!
Upvotes: 1
Views: 372
Reputation: 200080
As per the documentation for AppCompatButton, AppCompatButton
does not have a 4 argument constructor, despite View having a 4 argument constructors - constructors are treated differently from methods.
Upvotes: 1