Java 如何使用Android通用图像加载器使用ImageLoad

Java 如何使用Android通用图像加载器使用ImageLoad,java,android,android-listview,Java,Android,Android Listview,在我上一篇文章的主题中,我成功地在我的listview中显示了图像。结果证明在显示图像的过程中没有使用异步,我觉得listview很重。然后我试着使用图书馆。在我的库中,试图合并和替换我以前使用的ImageLoader库仍然有点困惑 我在我的活动和适配器中输入了onCreate: File cacheDir = StorageUtils.getCacheDirectory(this.getApplicationContext()); ImageLoaderConfiguratio

在我上一篇文章的主题中,我成功地在我的listview中显示了图像。结果证明在显示图像的过程中没有使用异步,我觉得listview很重。然后我试着使用图书馆。在我的库中,试图合并和替换我以前使用的ImageLoader库仍然有点困惑

我在我的活动和适配器中输入了
onCreate

File cacheDir = StorageUtils.getCacheDirectory(this.getApplicationContext());
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this.getApplicationContext())
            .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
            .discCacheExtraOptions(480, 800, CompressFormat.JPEG, 75, null)
            .threadPoolSize(3) // default
            .threadPriority(Thread.NORM_PRIORITY - 1) // default
            .tasksProcessingOrder(QueueProcessingType.FIFO) // default
            .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
            .memoryCacheSize(2 * 1024 * 1024)
            .memoryCacheSizePercentage(13) // default
            .discCache(new UnlimitedDiscCache(cacheDir)) // default
            .discCacheSize(50 * 1024 * 1024)
            .discCacheFileCount(100)
            .imageDownloader(new BaseImageDownloader(this.getApplicationContext())) // default
            .build();
        ImageLoader.getInstance().init(config);
在我的循环中(在
onPostExecute
中):

在以下部件上成为(使用
通用图像加载器
):

try {
        String urlImage = obj.getImg();
        if(urlImage.length() > 0){
            img.setTag(urlImage);
            imageLoader.displayImage(urlImage, img);
        }
    } catch (Exception e) {

    }

但在我的应用程序运行结束后,仍然无法显示图像。此库中是否缺少设置?请帮助

这似乎有点过分-对于一个使用异步加载并很好地处理列表视图的伟大库,请查看koush(著名的开发人员)

这是一个非常有用且易于理解的工具
public View getView(int position, View convertView, ViewGroup parent) {

        View v = inflater.inflate(R.layout.list_row, null);

        ImageView img       = (ImageView) v.findViewById(R.id.image);
        TextView judul      = (TextView) v.findViewById(R.id.judul);
        TextView tanggal    = (TextView) v.findViewById(R.id.tanggal);
        TextView isi        = (TextView) v.findViewById(R.id.isi);

        BeritaBean obj      = (BeritaBean) getItem(position);

        judul.setText(obj.getTitle());
        tanggal.setText(obj.getCreated());
        isi.setText(obj.getPost());

        try {
            String urlImage = obj.getImg();
            if(urlImage.length() > 0){
                img.setTag(urlImage);
                imageLoader.DisplayImage(urlImage, img);
            }
        } catch (Exception e) {

        }
        return v;
    }
try {
        String urlImage = obj.getImg();
        if(urlImage.length() > 0){
            img.setTag(urlImage);
            imageLoader.displayImage(urlImage, img);
        }
    } catch (Exception e) {

    }