使用Glide将1个图像加载到多个ImageView

时间:2016-11-28 13:25:08

标签: android android-glide

如何使用Glide将1个图像从服务器加载到多个imageView? 我试过这段代码:

Glide.with(ViewProductActivity.this)
        .load(LoginActivity.SERVER_URL+"/product/asset/"+listImageUrl.getString(i))
        .asBitmap()
        .placeholder(R.drawable.loading)
        .error(R.drawable.noimage)
        .signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
        .into(new SimpleTarget<Bitmap>() {
            @Override
            public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                ivImageChild.setImageBitmap(resource);
                ivImageMain.setImageBitmap(resource);
            }
        });

但是占位符()不起作用..如何解决?

1 个答案:

答案 0 :(得分:1)

只需为每张图片创建请求:)

Glide.with(ViewProductActivity.this)
  .load(LoginActivity.SERVER_URL+"/product/asset/"+listImageUrl.getString(i))
    .asBitmap()
    .placeholder(R.drawable.loading)
    .error(R.drawable.noimage)
    .signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
    .into(ivImageChild);

Glide.with(ViewProductActivity.this)
  .load(LoginActivity.SERVER_URL+"/product/asset/"+listImageUrl.getString(i))
    .asBitmap()
    .placeholder(R.drawable.loading)
    .error(R.drawable.noimage)
    .signature(new StringSignature(String.valueOf(System.currentTimeMillis())))
    .into(ivImageMain);