I have a horizontal recycleview inside vertical recycleview.
and i add list cardview inside horizontal rec
First, you create an interface like :
public interface OnItemClickListener{
void onItemClick(View view, int position)
}
Declare on global :
private OnItemClickListener mOnItemClickListener;
Next, you need a contructor like :
public MyAdapter(Context context, List data, OnItemClickListener mOnItemClickListener){
//...
this.mOnItemClickListener= mOnItemClickListener;
}
And in onBindViewHolder
@Override
public void onBindViewHolder(final FolderViewHolder holder, final int position) {
//....
holder.image.setOnClickListener(new View.OnItemClickListener){
@Override
public void onClick(View v) {
mOnItemClickListener.onItemClick(v,position);
}
});
}
Finally, you can implement Callback in class use adapter like :
public class A extends AppCombatActivity implements MyAdapter.OnItemClickListener{
//exist code
@Override
onItemClick(View view, int position){
// Do something with view + position
}
}