【发布时间】:2016-07-18 15:41:08
【问题描述】:
在 Kotlin 中有没有办法隐藏(放置在其他地方)视图的默认构造函数?也许创建一个子视图或扩展或类似的东西。
目前我所有的观点都是这样的,有点啰嗦:
class MyView(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int): View(context, attrs, defStyleAttr, defStyleRes) {
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int): this(context, attrs, defStyleAttr, 0)
constructor(context: Context, attrs: AttributeSet?): this(context, attrs, 0, 0)
constructor(context: Context): this(context, null, 0)
}
【问题讨论】: