+ 12
Kotlin/Android
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.
4 Answers
+ 1
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.
+ 1
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);
+ 1
activity to activity just to pass data is not good idea. use fragments instead. you just have to call this@<activity-class>.getActivity().field
- 3
c++