小编Asq*_*sqa的帖子

如何修复Kotlin中必需的Iterable但找到列表

您好我学习用kotlin构建应用程序,但是我收到此错误消息,提示“ Required Iterable,Found List”,我该如何解决此问题?请在下面查看我的代码谢谢

class MainActivity : AppCompatActivity(),ProductView {

private lateinit var productAdapter: ProductAdapter
private var productList: MutableList<ProductData> = mutableListOf()
private lateinit var dataPresenter : DataPresenter

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    initRecycler();
    getProduct()
}

private fun getProduct() {
    dataPresenter = DataPresenter(applicationContext,this)
    dataPresenter.getProduct()
}

private fun initRecycler() {
    productAdapter = ProductAdapter(this,productList)
    rvMain.layoutManager = LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false)
    rvMain.adapter = productAdapter
}

override fun showLoading() {
    pgMain.visibility = View.VISIBLE
}

override fun hideLoading() {
    pgMain.visibility = View.GONE
}

override fun showProduct(products: List<ProductData>?) { …
Run Code Online (Sandbox Code Playgroud)

android kotlin mutablelist

0
推荐指数
1
解决办法
199
查看次数

标签 统计

android ×1

kotlin ×1

mutablelist ×1