【发布时间】: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