Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Android-以下方法或属性之间的调用不明确_C#_Android_Xamarin - Fatal编程技术网

C# Android-以下方法或属性之间的调用不明确

C# Android-以下方法或属性之间的调用不明确,c#,android,xamarin,C#,Android,Xamarin,我在构建项目时遇到上述错误。方法引用的上下文不同,因此我不知道是什么导致了错误。我在应用程序中具有文件浏览功能。因此,根据称为浏览器的活动,用户可以选择文件夹或文件,并返回其路径 public class FileListAdapter : ArrayAdapter<FileSystemInfo> { private readonly Context _context; public FileListAdapter(Context context, IList<Fi

我在构建项目时遇到上述错误。方法引用的上下文不同,因此我不知道是什么导致了错误。我在应用程序中具有文件浏览功能。因此,根据称为浏览器的活动,用户可以选择文件夹或文件,并返回其路径

public class FileListAdapter : ArrayAdapter<FileSystemInfo>
{

private readonly Context _context;

    public FileListAdapter(Context context, IList<FileSystemInfo> fsi)
        : base(context, Resource.Layout.file_picker_list_item, Android.Resource.Id.Text1, fsi)
    {
        _context = context;
    }
    public override View GetView(int position, View convertView, ViewGroup parent)
    {
        var fileSystemEntry = GetItem(position);

        FileListRowViewHolder viewHolder;
        View row;



        if (convertView == null)
        {
            row = _context.GetLayoutInflater().Inflate(Resource.Layout.file_picker_list_item, parent, false);
            viewHolder = new FileListRowViewHolder(row.FindViewById<TextView>(Resource.Id.file_picker_text), row.FindViewById<ImageView>(Resource.Id.file_picker_image));
            row.Tag = viewHolder;
        }
        else
        {
            row = convertView;
            viewHolder = (FileListRowViewHolder)row.Tag;
        }
        viewHolder.Update(fileSystemEntry.Name, fileSystemEntry.IsDirectory() ? Resource.Drawable.folder : Resource.Drawable.file);

        return row;
    }



}

我解决了构建错误。这是一个很小的问题。上下文就是问题所在。因此我简单地将“有问题的上下文”更改为指向活动。由此:

public static LayoutInflater GetLayoutInflater(this Context context)
    {
        return context.GetSystemService(Context.LayoutInflaterService).JavaCast<LayoutInflater>();


    }
为此:

public static LayoutInflater GetLayoutInflater(Activity context)
    {
        return context.GetSystemService(Activity.LayoutInflaterService).JavaCast<LayoutInflater>();
    }
public static LayoutInflater GetLayoutInflater(this Context context)
    {
        return context.GetSystemService(Context.LayoutInflaterService).JavaCast<LayoutInflater>();


    }
public static LayoutInflater GetLayoutInflater(Activity context)
    {
        return context.GetSystemService(Activity.LayoutInflaterService).JavaCast<LayoutInflater>();
    }