Kevin Roberts Kevin Roberts - 5 months ago 32
Android Question

How to implement click listener in recyclerview?

I am new in android and learning about RecyclerView. I am working with json so that i can get data from server. I followed this tutorial for this. I am not getting how to implement onclicklistner on my recyclerview.


Following your tutorial, on the "bind data" method you can set a click listener. It will as easy as writing:

holder.itemView.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
        // write your code here


You will also need to change the

int position

to final, like:

public void onBindViewHolder(RecyclerView.ViewHolder viewHolder,final int position) {