I am implementing recycler view for my Xamarin android application and here is my recyclerviewadapter.cs code, but it is showing error on view when I pass it as parameter in constructor
namespace FinalProject_PU.Helper
{
class RecyclerViewHolder : RecyclerView.ViewHolder
{
public ImageView imageview { get; set; }
//
// public TextView Description { get; set; }
public RecyclerViewHolder(View itemView) : base(itemView)
{
imageview = itemView.FindViewById<ImageView>(Resource.Id.imageView1);
// Description = itemView.FindViewById<TextView>(Resource.Id.textView1);
}
}
class RecyclerViewAdapter : RecyclerView.Adapter
{
private List<Data> lstData = new List<Data>();
public RecyclerViewAdapter(List<Data> lstData)
{
this.lstData = lstData;
}
public override int ItemCount
{
get
{
return lstData.Count;
}
}
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
{
RecyclerViewHolder viewHolder = holder as RecyclerViewHolder;
viewHolder.imageview.SetImageResource(lstData[position].imageid);
//viewHolder.Description.Text = lstData[position].description;
}
public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
{
LayoutInflater inflater = LayoutInflater.From(parent.Context);
View itemView = inflater.Inflate(Resource.Layout.items, parent, false);
return new RecyclerViewHolder(itemView);
}
}
}
Here gives me 2 errors: 'View' is a namespace but is used like a type on this line
public RecyclerViewHolder(View itemView) : base(itemView)
and "The type or namespace name 'Data' couldn't be found(you are missing a using directive or an assembly refrence?) on this line
private List<Data> lstData = new List<Data>();
i have tried;
Use this code for the View errorAndroid.Views.View
it runs