Xamarin ImageView 继承 class 无法调用 getContext
Xamarin ImageView inherited class can't call getContext
```
public class MyImageView : ImageView
{
...
public override void SetImageResource(int resId)
{
var inputBitmap = ProcessImage(ContextCompat.GetDrawable(getContext(), resId));
}
...
}
```
在编译期间出现错误:
Controls/MyImageView.cs(...): error CS0103: The name 'getContext' does not exist in the current context
我做错了什么?
Xamarin/C# 规范化将是 read-only 属性 命名:Context
public override void SetImageResource(int resId)
{
var inputBitmap = ProcessImage(ContextCompat.GetDrawable(Context, resId));
}
```
public class MyImageView : ImageView
{
...
public override void SetImageResource(int resId)
{
var inputBitmap = ProcessImage(ContextCompat.GetDrawable(getContext(), resId));
}
...
}
```
在编译期间出现错误:
Controls/MyImageView.cs(...): error CS0103: The name 'getContext' does not exist in the current context
我做错了什么?
Xamarin/C# 规范化将是 read-only 属性 命名:Context
public override void SetImageResource(int resId)
{
var inputBitmap = ProcessImage(ContextCompat.GetDrawable(Context, resId));
}