android - onClick event on ViewHolder does work inside GridView -


my recyclerview has cardview , cardview contains 1 gridview , other textviews.

public mycardviewholder(view view) {     super(view);     this.view=view;     gridview = (gridview) view.findviewbyid(r.id.gridview);     nicknametextview =(textview) view.findviewbyid(r.id.card_nickname_textview);      ... }    

i set onclicklistener on viewholder when click inside gridview, click event never gets fired. here code onclicklistener:

view.setonclicklistener(new view.onclicklistener() {     @override     public void onclick(view v) {         ...     }); } 

thanks help.

following code can proceed click events element :)

public class homerecycleradapter extends recyclerview.adapter<recyclerview.viewholder> implements view.onclicklistener {       private list<string> mitemlist;      recyclerview mrecyclerview;      context context;     homeitemviewholder mhomeitemholder;      public homerecycleradapter(list<string> itemlist) {         mitemlist = itemlist;     }       public class homeitemviewholder extends recyclerview.viewholder {          imageview mimage;           public homeitemviewholder(view parent) {             super(parent);              mimage = (imageview) parent.findviewbyid(r.id.image);           }      }      public homerecycleradapter(list<string> itemlist, context context, recyclerview mrecyclerview) {         this.mitemlist = itemlist;         this.context = context;         this.mrecyclerview = mrecyclerview;       }       @override     public recyclerview.viewholder oncreateviewholder(viewgroup parent, int viewtype) {         context context = parent.getcontext();          final view view = layoutinflater.from(context).inflate(r.layout.item_home, parent, false);           return new homeitemviewholder(view);      }       @override     public void onbindviewholder(recyclerview.viewholder viewholder, final int position) {          mhomeitemholder = (homeitemholder) viewholder;                    mhomeitemholder.mimage.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                  //handle code             }         });      }               public int getbasicitemcount() {         return mitemlist == null ? 0 : mitemlist.size();     }       @override     public int getitemcount() {         return getbasicitemcount(); // header      }    } 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -