https://kotlinlang.org logo
#android
Title
# android
a

arekolek

09/24/2019, 3:10 PM
I think it is becoming common knowledge that using
@JvmOverloads
for custom views on Android can bite you if you don’t do it properly. What I haven’t seen in this discussion yet, is that most probably (because in Kotlin
final
is the default), you only need the 2 constructors in your custom view, and so you should be just fine using
@JvmOverloads
for it. https://medium.com/@arekolek/all-your-classes-are-final-so-why-do-you-even-need-the-3-argument-constructor-d35553dd6347 What do you think?
👍 2
w

wasyl

09/24/2019, 3:49 PM
Afaik you only need one constructor if you’re creating the view from the xml, the one with two parameters
👍 2
a

arekolek

09/24/2019, 4:08 PM
That’s a good point