【问题标题】:can't load images in Image View using glide无法使用滑行在图像视图中加载图像
【发布时间】:2019-03-25 00:40:50
【问题描述】:

我正在使用 glide 库在网格视图中显示图像,但在我的图像视图中显示了注释。我得到一个错误:

E/Glide:com.bumptech.glide.load.engine.GlideException 类:失败 加载资源

当我使用位图时,我的代码可以正常工作。这是我的代码:

    @Override
        public View getView(final int position,  View convertView, ViewGroup parent) {
            Log.e("sara" , "this part takes time");


            LayoutInflater inflater = getLayoutInflater();


            convertView = getLayoutInflater().inflate(R.layout.gallery_gridsq, parent, false);
            iv = (ImageView) convertView.findViewById(R.id.icon);
            file = new File(Uri.parse(getItem(position).toString()).getPath());
            Uri imageUri = Uri.fromFile(file);
            Glide
                    .with(Gallery2.this)
                    .load(imageUri)
                    .into(iv);


            return convertView;
        }

【问题讨论】:

  • 尝试给出文件路径而不是uri
  • @RahimRahimli 结果和 uri 一样 :(
  • 请记录此行Uri.parse(getItem(position).toString()).getPath() 以确保它返回正确的路径。
  • 您的图片保存在哪里?是本地的还是服务器上的?
  • @kapsym 它是本地的 :)

标签: android gridview android-glide


【解决方案1】:

关于在 Github 上 Glide 看到这个issue 可能会对你有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-29
    • 2017-02-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多