基于这个讨论: Universal Image Loader - Image URL 404 Error handling
我制作图像加载器。它工作得很好! 但就我而言,服务器上删除的图像文件已过期。我希望为此缓存查询 URL 404,但未缓存,并且每次当我向下滚动此待处理图像 URL 中的 ListView 以获取 404 时都会发生。它如何缓存?
最佳答案
这是很晚的答案,但它会帮助其他人,答案只是在这里解释,
DisplayImageOptions options = new DisplayImageOptions.Builder()
.resetViewBeforeLoading(false).delayBeforeLoading(10)
.showImageOnFail(null).showImageForEmptyUri(null) // this will intitate null if there is loading fail or empty url
.cacheInMemory(true).cacheOnDisc(true).handler(new Handler())
.build();
并使用这个处理 404
ImgLoader.displayImage(Globals.Image_Domain + largeimageUrl,
largeImage, Base.options, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view,
FailReason failReason) {
// TODO Auto-generated method stub
// This will handle 404 and it will catch null exception
// do here what you want to do
}
@Override
public void onLoadingComplete(String imageUri,
View view, Bitmap loadedImage) {
// TODO Auto-generated method stub
if (largeImage == null)
return;
largeImage.setImageBitmap(loadedImage);
}
@Override
public void onLoadingCancelled(String imageUri,
View view) {
}
});
关于android - 通用图像加载器 - 不缓存 URL 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20316234/