5,380 questions
RecyclerView ViewHolder Parent is null
Nathan Sokalski
4,111
Reputation points
I have a RecyclerView Adapter for which I need to access the RecyclerView in OnBindViewHolder. Here is the code from OnCreateViewHolder:
public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
{ return new NetWinsValuesViewHolder(LayoutInflater.From(parent.Context).Inflate(Resource.Layout.NetWinsValuesLayout, parent, false)); }
In OnBindViewHolder I have the following:
NetWinsValuesViewHolder vh = holder as NetWinsValuesViewHolder;
RecyclerView rvavgnetwins = vh.llRoot.Parent as RecyclerView;
However, vh.llRoot.Parent
ends up being null. I have used this technique to access the RecyclerView plenty of times in the past, so why is it returning null here?
Developer technologies .NET Xamarin
Sign in to answer