项目转为Kotlin,部分代码Java转Kotlin时报错如下
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter convertView
val tagAdapter = object : TagAdapter<String?>() {
override fun getView(position: Int, convertView: View, parent: ViewGroup): View {
val textView = ColorfulTagView(UIUtils.getContext())
textView.text = getItem(position) as String
return textView
}
}
这是Kotlin安全机制的检测,需要在方法中加入 ?