FFImageLoading 从 Mobile-Sdcard 加载图像

FFImageLoading Load image from Mobile-Sdcard

我正在尝试从手机加载图像。 与 picasso 相同的方法工作正常,但我在使用 FFImageloading

时遇到问题
var CatalogCategories = System.IO.Path.Combine(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures).ToString(), "dbsoft");
ImageService.Instance.LoadFile(new Java.IO.File(CatalogCategories, "Main.jpg")).Into(MainImage);

我收到错误 CS1503 参数 1:无法从 'Java.IO.File' 转换为 'string'

LoadFile方法的参数应该是string.

/// <summary>
/// Constructs a new TaskParameter to load an image from a file.
/// </summary>
/// <returns>The new TaskParameter.</returns>
/// <param name="filepath">Path to the file.</param>
TaskParameter LoadFile(string filepath);

您需要使用 File 的 AbsolutePath 属性 来获取字符串路径:

ImageService.Instance.LoadFile(new Java.IO.File(CatalogCategories, "Main.jpg").AbsolutePath).Into(MainImage);

更新

Into方法的参数应该是ImageViewAsync,所以你应该在布局中使用ImageViewAsync

<FFImageLoading.Views.ImageViewAsync
    android:id="@+id/mainImage"
    android:scaleType="centerCrop"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

在您的 .cs 文件中:

ImageViewAsync MainImage = FindViewById<ImageViewAsync>(Resource.Id.mainImage);