Xamarin安卓C#”;iCursor在当前上下文中不存在”;

Xamarin安卓C#”;iCursor在当前上下文中不存在”;,c#,android,xamarin.android,android-cursor,C#,Android,Xamarin.android,Android Cursor,我遵循了Xamarin(这里:)的一个示例,介绍了如何允许用户导航他们的android设备,并选择一个图像。然而这条线 使用(ICursor cursor=ManagedQuery(uri、投影、null、null、null)) 抛出错误“错误CS0103:名称“ICursor”在当前上下文中不存在” 这也使游标方法的任何实现陷入困境 这是我的密码: public class Profile : Activity { public static readonly int PickI

我遵循了Xamarin(这里:)的一个示例,介绍了如何允许用户导航他们的android设备,并选择一个图像。然而这条线 使用(ICursor cursor=ManagedQuery(uri、投影、null、null、null)) 抛出错误“错误CS0103:名称“ICursor”在当前上下文中不存在”

这也使游标方法的任何实现陷入困境

这是我的密码:

public class Profile : Activity
{   
    public static readonly int PickImageId = 1000;
    private ImageView _imageView;

    protected override void OnCreate (Bundle bundle)
    {

        base.OnCreate (bundle);

        SetContentView (Resource.Layout.Profile);
        _imageView = FindViewById<ImageView>(Resource.Id.imageView1);
        Button button = FindViewById<Button>(Resource.Id.MyButton);
        button.Click += ButtonOnClick;

        _OKButton.Click += delegate(object sender, EventArgs e) 
        {
            string firstname,surname,country,city,IAmA,bio;
            firstname = _FirstNameBox.Text;
            surname = _SurnameBox.Text;
            country = _CountryBox.Text;
            city = _CityBox.Text;
            //IAmA = spinner_ItemSelected;
            IAmA = "Bassist";
            bio = "";

            sendProfileToCloud(firstname,surname,country,city,IAmA,bio);

        };
    }
    private void ButtonOnClick(object sender, EventArgs eventArgs)
    {
        Intent = new Intent();
        Intent.SetType("image/*");
        Intent.SetAction(Intent.ActionGetContent);
        StartActivityForResult(Intent.CreateChooser(Intent, "Select Picture"), PickImageId);
    }

    protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
    {
        if ((requestCode == PickImageId) && (resultCode == Result.Ok) && (data != null))
        {
            Uri uri = data.Data;
            _imageView.SetImageURI(uri);

            string path = GetPathToImage(uri);
            Toast.MakeText(this, path, ToastLength.Long);
        }
    }

    private string GetPathToImage(Uri uri)
    {
        string path = null;
        // The projection contains the columns we want to return in our query.
        string[] projection = new[] { Android.Provider.MediaStore.Images.Media.InterfaceConsts.Data };
        using (ICursor cursor = ManagedQuery(uri, projection, null, null, null))
        {
            if (cursor != null)
            {
                int columnIndex = cursor.GetColumnIndexOrThrow(Android.Provider.MediaStore.Images.Media.InterfaceConsts.Data);
                cursor.MoveToFirst();
                path = cursor.GetString(columnIndex);
            }
        }
        return path;
    }
}
公共类配置文件:活动
{   
公共静态只读int-PickImageId=1000;
私有ImageView _ImageView;
创建时受保护的覆盖无效(捆绑包)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Profile);
_imageView=FindViewById(Resource.Id.imageView1);
Button Button=FindViewById(Resource.Id.MyButton);
按钮。单击+=按钮单击;
_确定按钮。单击+=委托(对象发送者,事件参数e)
{
字符串名字、姓氏、国家、城市、IAmA、bio;
firstname=\u FirstNameBox.Text;
姓氏=_namesbox.Text;
country=\u CountryBox.Text;
城市=_CityBox.Text;
//IAmA=所选微调器项目;
IAmA=“贝斯手”;
bio=“”;
sendProfileToCloud(名字、姓氏、国家、城市、IAmA、bio);
};
}
私有void按钮nonclick(对象发送方,EventArgs EventArgs)
{
Intent=新Intent();
Intent.SetType(“image/*”);
Intent.SetAction(Intent.ActionGetContent);
StartActivityForResult(Intent.CreateChooser(Intent,“选择图片”),PickImageId);
}
受保护的覆盖void OnActivityResult(int请求代码、结果代码、意图数据)
{
if((requestCode==PickImageId)&&&(resultCode==Result.Ok)&&(data!=null))
{
Uri=data.data;
_SetImageURI(uri);
字符串路径=GetPathToImage(uri);
MakeText(this,path,ToastLength.Long);
}
}
私有字符串GetPathToImage(Uri)
{
字符串路径=null;
//投影包含我们希望在查询中返回的列。
string[]projection=new[]{Android.Provider.MediaStore.Images.Media.InterfaceConsts.Data};
使用(ICursor cursor=ManagedQuery(uri、投影、null、null、null))
{
如果(光标!=null)
{
int columnIndex=cursor.GetColumnIndexOrThrow(Android.Provider.MediaStore.Images.Media.InterfaceConsts.Data);
cursor.MoveToFirst();
path=cursor.GetString(columnIndex);
}
}
返回路径;
}
}
提前感谢您的帮助