【发布时间】:2019-11-06 17:15:15
【问题描述】:
我有这个sn-ps:
class RecyclerViewAdapter internal constructor(
val clazz: Class<out RecyclerViewViewHolder>,
val layout: Int,
var dataList: MutableList<*>)
...
...
...
fun RecyclerView.getDataList() : ArrayList<*> {
return (adapter as RecyclerViewAdapter).dataList as ArrayList<*>
}
...
...
...
然后我在这个上使用它:
recyclerView.getDataList().add(Person("Lem Adane", "41 years old", 0))
但我收到此错误:
Error:(19, 31) Out-projected type 'ArrayList<*>' prohibits the use of
'public open fun add(index: Int, element: E): Unit defined in
java.util.ArrayList'
【问题讨论】:
标签: generics kotlin kotlin-android-extensions kotlin-extension