【发布时间】:2018-03-20 15:51:29
【问题描述】:
在我的 xamarin.forms 项目中,我得到了一张图片。 此图像有一个看起来像这样的渲染器:
public class CustomImage : Image
{
public event EventHandler<PointEventArgs> TapEvent;
public void OnTapEvent(int x, int y)
{
TapEvent?.Invoke(this, new PointEventArgs(x, y));
}
}
Android 渲染器如下所示:
public class ImageRendererAndroid : ImageRenderer
{
private ImageView nativeElement;
private CustomImage formsElement;
protected override void OnElementChanged(ElementChangedEventArgs<Image> e)
{
base.OnElementChanged(e);
if (e.NewElement != null)
{
if (Control != null)
{
Control.Clickable = true;
Control.SetOnTouchListener(ImageTouchListener.Instance.Value);
Control.SetTag(Control.Id, new JavaObjectWrapper<CustomImage> { Obj = Element as CustomImage });
}
}
}
}
当我调用 Control.setTag 方法时,我收到以下错误:
Java.Lang.IllegalArgumentException: The key must be an application-specific resource id.
Control.Id 为 157
那么为什么我会收到这个错误,我该如何解决呢?
谢谢
【问题讨论】:
标签: android image xamarin.forms