79836835

Date: 2025-12-03 11:50:55
Score: 1
Natty:
Report link

If to use this in Android kotlin
Adapter :-
class Adapter(private val onIconClick: (Int) -> Unit) : RecyclerView.Adapter<MovieAdapter.ViewHolder>() likeIcon.setOnClickListener(){

onIconClick(0);

}

Screen :-
private fun prepareRecyclerView() {

movieAdapter = MovieAdapter({icon ->

Toast.makeText(applicationContext, "clicked", Toast.LENGTH_SHORT).show()    

})

binding.rvMovies.apply {

adapter = movieAdapter

}

}

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Shah Suhail