public class TransportAdapter extends RecyclerView.Adapter<TransportAdapter.TransportViewHolder> {
public interface onClickListener{
void onVariantClick(TransportModel model);
}
private onClickListener listener;
.....
@Override
public void onBindViewHolder(@NonNull TransportViewHolder holder, int position) {
final TransportModel transportModel = transportVariants.get(position);
....
if(listener != null){
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
listener.onVariantClick(transportModel);
}
});
}
}
.... бла бла бла
public void setListener(onClickListener listener){
this.listener = listener;
}
class TransportViewHolder extends RecyclerView.ViewHolder {
.....бла бла бла
public TransportViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
}
}
}