使用Glide无法刷新验证码图像 [英] Captcha image cannot be refresh by using Glide

查看:748
本文介绍了使用Glide无法刷新验证码图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Glide将Captcha图像加载到ImageView中。第一次加载很好。但是,当我将Captcha图像重新加载到同一个ImageView中时,ImageView不会刷新到新图像。有谁知道如何解决这个问题?

I have tried to use Glide to load an Captcha image into a ImageView. The first time loading is fine. However, when I reload the Captcha image into the same ImageView, the ImageView does not refresh to new image. Does anyone have idea how to solve this issue?

String url = "https://captcha_path";
ImageView imgView = (ImageView)getActivity().findViewById(R.id.imgView);

Glide.with(getActivity()).load(url).asBitmap().diskCacheStrategy(DiskCacheStrategy.NONE).into(imgView);


推荐答案

你总是可以使用 Glide.clear()和然后再次调用Glide.with(...)。load()。如果图像更改时您的网址没有更改,您可能还需要添加。skipMemoryCache(true)加载调用。要获得更多控制权,请查看 .signature() API。您可以随时执行以下操作:

You can always use Glide.clear() and then call Glide.with(...).load() again. If your url doesn't change when the image changes, you may also need to add .skipMemoryCache(true) to your load call. For more control, check out the .signature() API. You can always do something like:

Glide.with(fragment)
    .load(url)
    .signature(new StringSignature(UUID.randomUUID().toString()))
    .into(imgView);

这篇关于使用Glide无法刷新验证码图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆