如何使用通用图像加载器 [英] How to use Universal Image Loader

查看:26
本文介绍了如何使用通用图像加载器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求,我需要在 ListView 中加载缩略图和一个 Text,它由自定义 Adapter 设置.缩略图应该存储在缓存中,因为我使用的是通用图像加载器,但是我对它的实现以及如何根据我的要求使用它来加载 ListView<中的图像感到非常困惑/code> 来自 URL.请建议我一些可以很好实施的方法.

I have a requirement where I need to load thumbnails and a Text in ListView which gets set by the custom Adapter. The Thumbnails should be stored in a cache memory, for that I am using the Universal Image Loader however I am pretty much confused in the implementation of it and how to use it as per my requirement in to load the images in ListView from URL. Please suggest me some ways for it with good implementation.

推荐答案

将下面的代码写入适配器的 getView() 方法中,这里 imageUrls[position] 是 Image Urls 数组,holder.image 是 imageview.

Write below code line into your adapter's getView() method, here imageUrls[position] is array of Image Urls and holder.image is imageview.

imageLoader.displayImage(imageUrls[position], holder.image, null);

并将以下代码行写入您的适配器构造函数.

And write below code line into your adapter constructor.

ImageLoader imageLoader=new  ImageLoader(activity.getApplicationContext());

它将解决您的问题,如果您对此有任何疑问,请告诉我.

it will solve your problem, And if you have any query regarding that then tell me.

有关通用图像加载程序示例的完整源代码,请参阅以下链接.

And see below link for complete source code of Universal Image Loader Example.

Android - 通用图像加载器

这篇关于如何使用通用图像加载器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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