加载从标清图像到ListView中时提高效率的ListView中时、提高效率、图像、加载

2023-09-06 14:24:59 作者:Man In The Mirror 镜中人

我使用的是自定义适配器为我的ListView按照由罗曼盖伊高效的适配器样品。

I am using a custom adapter for my ListView as per the efficient adapter sample by Romain Guy.

在我的适配器,我用下面的code分配一个ImageView的一幅JPG格式存储到SD的getView()方法:

In the getView() method of my adapter I am assigning an ImageView a jpg image stored on SD using the following code :

File f=new File(MovieThumbs.get(position));

if(f.length() > 0) {
    holder.thumb.setImageBitmap(BitmapFactory.decodeFile(MovieThumbs.get(position)));
}

在通过使用这种方法从坏口吃应用程序遭受,因为它试图处理图像约200项的列表弹。

When flicking through a list of some 200 items using this method the app suffers from bad stuttering as it tries dealing with the images.

有没有更有效的解决方案呢?

Is there a more efficient solution for this?

推荐答案

图片需要在后台线程处理。需要回收的观点来加以考虑。我试图解决所有这些问题,我的样本code,现在工作得很好,你可以看看http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview/3068012#3068012

Images need to be processed in background thread. Recycled views need to be taken into account. I try to address all these issues in my sample code, it works fine now, you may take a look http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview/3068012#3068012