我必须实现MvxGridView自定义适配器。MvxGridView自定义适配器
根据绑定类型,此适配器应该使视图膨胀并设置图像资源。
我可以直接覆盖GetView在MvxAdapter?
public override View GetView(int position, View convertView, ViewGroup parent)
{
var inflater = (LayoutInflater)this.Context.GetSystemService(Context.LayoutInflaterService);
var productNode = (ProductNode)this.GetRawItem(position);
if (productNode.NodeType == ProductNodeType.Folder)
{
return inflater.Inflate(Resource.Layout.GridFolderItem, parent);
}
else
{
View documentItemView = inflater.Inflate(Resource.Layout.GridDocumentItem, parent);
var imageView = documentItemView.FindViewById<MvxImageView>(Resource.Layout.GridFolderItem);
switch (productNode.NodeType)
{
case ProductNodeType.Unknown:
throw new InvalidOperationException("Node type hasn't been initialized");
case ProductNodeType.Image:
// Set matching image
break;
case ProductNodeType.Pdf:
break;
case ProductNodeType.Parts:
break;
default:
throw new InvalidOperationException(
string.Format("Unhandled node type '{0}'", productNode.NodeType));
}
return imageView;
}
}
或者我应该重写GetBindableView?
在这种情况下,我真的不知道如何处理没有父母的ViewGroup通货膨胀...