Passing a listener object as a function parameter in kotlin

后端 未结 2 797
死守一世寂寞
死守一世寂寞 2020-12-07 02:34

I\'m trying to pass a listener from an action to a class (an adapter).

In java (code from the Action):

  private void setListeners() {
    adapterRe         


        
2条回答
  •  有刺的猬
    2020-12-07 03:00

    Change

    adapterRecyclerView!!.setListener  { v  ->
                          SomeCodehere....
    }
    

    to

    adapterRecyclerView!!.setListener(object : View.OnClickListener {
    
    })
    

    and implement the methods of View.OnClickListener

提交回复
热议问题