0
我做的,告訴我照片Xamarin項卡上單擊RecyclerView
對於爲例(不包括下面的文字)回收,並且卡視圖:
我對每一張照片的詳細信息,如:位置,名稱等。
現在,我想點擊照片,而不是照片,我會看到我點擊的照片的詳細信息。
這是我的代碼:
class RecyclerViewHolder : RecyclerView.ViewHolder
{
public ImageView ImageView { get; set; }
public RecyclerViewHolder(View itemView) : base(itemView)
{
ImageView = itemView.FindViewById<ImageView>(Resource.Id.imageView);
}
}
class RecyclerViewAdapter : RecyclerView.Adapter
{
private List<PetEntity> _lstData;
public RecyclerViewAdapter(List<PetEntity> lstData)
{
_lstData = lstData;
}
public override int ItemCount => _lstData.Count;
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
{
RecyclerViewHolder viewHolder = holder as RecyclerViewHolder;
var image = ImageHelper
.GetImageBitmapFromUrl(_lstData[position].PictureURL);
if (image == null)
viewHolder.ImageView.SetImageBitmap(
ImageHelper.GetImageBitmapFromUrl(
StaticConst.Uri + "Content/NA.png"
));
else
viewHolder.ImageView.SetImageBitmap(image);
}
public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
{
View itemView = LayoutInflater.From(parent.Context).
Inflate(Resource.Layout.item, parent, false);
RecyclerViewHolder vm = new RecyclerViewHolder(itemView);
return vm;
}
}
我嘗試了一些東西,但沒有成功,所以我沒有添加到我的代碼在這裏。