android - Onclick of recyclerview nothing happens -


adapter of recyclerview

public class songsadapter extends recyclerview.adapter<songsadapter.myviewholder>{     context context;     arraylist<hashmap<string, string>> songlist;      public songsadapter(arraylist<hashmap<string, string>> songlist,context context) {         this.songlist = songlist;         this.context=context;     }      @override     public myviewholder oncreateviewholder(viewgroup parent, int viewtype) {         view view = layoutinflater.from(parent.getcontext()).inflate(r.layout.list_item, parent, false);         return new myviewholder(view,context);      }      @override     public void onbindviewholder(myviewholder holder, int position) {          holder.textview.settext(songlist.get(position).get("file_name"));     }      @override     public int getitemcount() {         return songlist.size();     }      public class myviewholder extends recyclerview.viewholder  implements view.onclicklistener {         private textview textview;         context context;          public myviewholder(view itemview, context context){             super(itemview);             this.context = context;             textview=(textview)itemview.findviewbyid(r.id.listitemtextview);          }          @override         public void onclick(view v) {             int position=getadapterposition();             log.d(tag, "onclick: ");             toast.maketext(context,"hi",toast.length_long).show();         }     }  } 

list_item

<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.cardview   xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:elevation="4dp"     android:backgroundtint="@color/tan_background"     android:padding="8dp"     android:layout_margin="20dp"    >      <linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content">      <textview         android:layout_width="match_parent"         android:layout_height="50dp"         android:textstyle="bold"         android:id="@+id/listitemtextview"/>      </linearlayout>  </android.support.v7.widget.cardview> 

on click of recyclerview not working.i want move next activity on click of recyclerview. please help.i tried doing nothing works.i went through stackoverflow's question related same topic.i dont have onclick=true in cardview layout

add itemview.setonclicklistner(this) inside public myviewholder(view itemview, context context)


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -