Kotlin/Android | SoloLearn: Learn to code for FREE!



How to start new activity by clicking an item in recycler view and also pass data to new activity while doing this?(using Kotlin) Thanks in advanced.

10/14/2018 7:32:03 AM


4 Answers

New Answer


I haven't used kotlin for android yet but have been using java. In java, you need to set an onClicklistener on the itemview in the adapter you have used with recyclerview. There is no direct listener which can be set on recyclerview for an item. I guess the same thing applys in kotlin. Hope it helps.


It's basically like Java. The easiest way would be is to set an onclicklistener to the "viewHolder" in onBindViewholder and then call startActivity(intent); intent.putExtra("INDEX",data);


activity to activity just to pass data is not good idea. use fragments instead. you just have to call [email protected]<activity-class>.getActivity().field