我有这个片段:
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'