将 kotlin 版本更新到 1.3.0 后,我遇到了上述问题
下面是代码,
public class SequenceLayout(context: Context?, attrs: AttributeSet?, defStyleAttr: Int)
: FrameLayout(context, attrs, defStyleAttr), ViewTreeObserver.OnGlobalLayoutListener {
}
第一行我明白了。问题 。请帮我解决这个问题。
最佳答案
签名错误。创建 View 时 Context 不能为 null,而 AttributeSet 可以。改变它就像
public class SequenceLayout(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
关于android - 类型不匹配 : inferred type is Context? 但需要上下文 - Kotlin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55257199/