Browsed by
Month: May 2019

Android recycler view item click listener from Activity or Fragment

Android recycler view item click listener from Activity or Fragment

First Create an interface . NotfallKontakteEntity is Model of list items Then in adapter define and create constructor with click listener public OnItemClickListener listener;public NotfallKontakteAdapter(List<NotfallKontakteEntity> notfallKontakteEntityList, OnItemClickListener listener) { this.notfallKontakteEntityList = notfallKontakteEntityList; this.listener = listener;} Now just declare it any click item view OnClickListener . Must add the item position as parameter. Now time to user this click listener. We can use anywhere in our fragment or activity