kotlin.TypeCastException: null cannot be cast to non-null type kotlin.collections.MutableList

前端 未结 3 1157
独厮守ぢ
独厮守ぢ 2021-01-29 05:04

please dont marked as duplicate , as the question is slightly different ---> null cannot be cast to non-null type kotlin.collections.MutableList

3条回答
  •  孤街浪徒
    2021-01-29 05:41

    Can't find a reason to use MutableList but your issue is incorrect type cast (dataList as MutableList). This is cause null cannot be cast to non-null type. You can simplify code using class CartAdapter(private val context: Context, private val dataList: ArrayList?) and remove var dataList: MutableList, private val context: Context and init{}

提交回复
热议问题