Kevin Roberts Kevin Roberts - 1 year ago 75
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.

Answer Source

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) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download