我有一个MvxAdapter来查看MvxGridview中的图像。一切正常,直到我从ItemSource中删除一个项目。
我的视图不会升级(GetView() - 在删除项目后不调用Method)。但为什么呢?
我在ItemsSource-Collection更改后调用了以下方法(不依赖于删除或添加项目)
RunOnUiThread(() => _adapter.NotifyDataSetChanged());
适配器创建如下:
// Create adapter
_adapter = new CustomAdapter(this, (IMvxAndroidBindingContext)BindingContext);
// Get gridview and set adapter
var gridview = FindViewById<MvxGridView>(Resource.Id.uploadprogress_imagegrid);
gridview.Adapter = _adapter;
这里是GetView() - CustomAdapter的方法
protected override View GetView(int position, View convertView, ViewGroup parent, int templateId)
{
var data = GetRawItem(position) as PhoneImageItem;
if (data == null) return null;
ViewHolder holder;
if (convertView == null)
{
convertView = _context.LayoutInflater.Inflate(templateId, parent, false);
holder = new ViewHolder
{
Image = convertView.FindViewById<ImageView>(Resource.Id.phonepictures_item),
Foreground = convertView.FindViewById<LinearLayout>(Resource.Id.phonepictures_foreground)
};
convertView.Tag = holder;
}
else
{
holder = (ViewHolder)convertView.Tag;
}
// Get bitmap from lru-cache
var bmp = GetBitmapFromMemCache(data.Filepath);
if (bmp == null)
{
LoadBitmap(data.Filepath, holder.Image);
}
else
{
// Set bitmap from cache
holder.Image.SetImageBitmap(bmp);
}
// Set selected-layout
holder.Foreground.Visibility = (data.IsSelected) ? ViewStates.Visible : ViewStates.Invisible;
return convertView;
}
我不知道该怎么做。谁能帮我?感谢