I have a use case where I need a reference to the parent RecyclerView
from inside the adapter, specifically inside the onBindViewHolder
method. So far
Another way is passing a reference in the constructor, e.g.
public final class MyAdapter extends RecyclerView.Adapper {
private final recyclerView;
public MyAdapter(@NonNull RecyclerView recyclerView) {
this.recyclerView = recyclerView;
}
...
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
...
}
}