从pagedList适配器调用接口-Android Kolin

从pagedList适配器调用接口-Android Kolin,android,kotlin,Android,Kotlin,如何从android kotlin中的页面列表回收器适配器调用接口?请ehelp您必须以某种方式将接口作为参数传递,一种方法是在构造函数上 class YourAdapterImplementation( private val delegate: YourDelegateInterface ) : PagedListAdapter<YourModelClass, YourViewHolderClass>( yourDiffCallback ) { //..

如何从android kotlin中的页面列表回收器适配器调用接口?请ehelp

您必须以某种方式将接口作为参数传递,一种方法是在构造函数上

class YourAdapterImplementation(
    private val delegate: YourDelegateInterface
) : PagedListAdapter<YourModelClass, YourViewHolderClass>(
    yourDiffCallback
) {

    //... the rest of the mandatory code

   onBindViewHolder(...) {
       holder.someView.setOnClickListener {
           delegate.someMethod(...)
       }
   }

}

class YourFragment : Fragment, YourDelegateInterface {

    onViewCreated() {
         //the view code
         val adapter = YourAdapterImplementation(this)
         recycler.adapter = adapter
    }

    //the interface methods fully implemented
    override someMethod(...) {....}

}