简体   繁体   English

如何在 kotlin 中的片段中设置 recyclerview 适配器

[英]how to set recyclerview adapter in fragment in kotlin

The below error is displayed.显示以下错误。

I'm trying to set the adapter on onViewCreated Lifecycle method in Fragment.我正在尝试在 Fragment 的 onViewCreated Lifecycle 方法上设置适配器。

Try using image_recyclerview.adapter = picture_adapter(infos, this, this)尝试使用 image_recyclerview.adapter = picture_adapter(infos, this, this)

In kotlin you don't have to use 'setAdapter' but instead you can just use adapter.在 kotlin 中,您不必使用“setAdapter”,而是可以只使用适配器。 When trying to do this remember that it's not a function invocation.尝试执行此操作时请记住,这不是函数调用。 Instead you can use it like this:相反,您可以这样使用它:

imageRecyclerView.adapter = picture_Adapter(infos, this, this)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在kotlin中如何设置recyclerview适配器的单击事件 - in kotlin how to set click event for recyclerview adapter 如何在片段中将Null设置为RecyclerView适配器 - How to set Null to RecyclerView adapter In fragment Kotlin:如何将数据从RecyclerView适配器发送到Fragment - Kotlin: How to send data from RecyclerView adapter to a Fragment 如何在 Kotlin 中对 Activity 和 Fragment 使用相同的 RecyclerView 适配器? - How to use the same RecyclerView adapter with Activity and Fragment in Kotlin? 如何在带有Fragment的RecyclerView适配器中使用RecyclerView? - How to use RecyclerView in RecyclerView adapter with Fragment? MVVM设置Recyclerview适配器以及片段中的项目 - MVVM Set Recyclerview Adapter With Items In Fragment 嵌套的内部片段无法将适配器设置为recyclerView - Nested inner fragment not able to set adapter to recyclerView 如何从 RecyclerView 适配器(Kotlin)评估片段中的变量(更改值)以进行条件处理? - How to evaluate a variable (changing value) in a Fragment from a RecyclerView Adapter (Kotlin) for conditional processing? 如何在 Fragment 中设置适配器 - How to set adapter in Fragment 如何从同一片段中的其他 recyclerview 适配器刷新 recyclerview 适配器 - How to refresh recyclerview adapter from other recyclerview adapter in same fragment
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM