什么是LazyList? [英] What's LazyList?

查看:250
本文介绍了什么是LazyList?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到任何真正可靠的消息来源解释什么LazyList是。有人吗?

I can't find in any really credible source explaining what LazyList is. Anyone?

推荐答案

懒列表从SD卡或从服务器中使用的URL的图像延迟加载。这就像按需加载图像。

Lazy List is lazy loading of images from sd-card or from server using urls. It is like on demand loading images.

图像可以被缓存到本地SD卡或手机内存。 URL被视为关键。如果关键是从服务器下载并缓存同样为您选择的位置present在SD卡,从SD卡还显示图像的显示图像。缓存限制可以设置。您也可以选择自己的位置,以高速缓存图像。缓存也被清除。

Images can be cached to local sd-card or phone memory. Url is considered the key. If the key is present in sd-card, display images from sd-card else display image by downloading from server and cache the same to location of your choice. The cache limit can set. You can also choose your own location to cache images. Cache can also be cleared.

而不是等待用户下载大量的图像,然后显示懒列表,加载图像的需求。由于图像的缓存,可以显示图像脱机。

Instead of user waiting to download large images and then displaying lazy list, loads images on demand. Since images are cached you can display images offline.

https://github.com/thest1/LazyList 。懒列表

在你getview

imageLoader.DisplayImage(imageurl, imageview);

ImageLoader的显示方法

ImageLoader Display method

    public void DisplayImage(String url, ImageView imageView) //url and imageview as parameters
    {
    imageViews.put(imageView, url);
    Bitmap bitmap=memoryCache.get(url);   //get image from cache using url as key
    if(bitmap!=null)         //if image exists
        imageView.setImageBitmap(bitmap);  //dispaly iamge
     else   //downlaod image and dispaly. add to cache.
     {
        queuePhoto(url, imageView);
        imageView.setImageResource(stub_id);
     }
   }

这是另一种懒列表是通用图像装载机

An alternative to Lazy List is Universal Image Loader

<一个href="https://github.com/nostra13/Android-Universal-Image-Loader">https://github.com/nostra13/Android-Universal-Image-Loader.它是基于懒列表(在相同的原则也适用)。但它有许多其它配置。我想preFER使用的 *的通用图像装载机的* 怎么把它给你更多的配置选项。您可以显示一个错误的形象,如果立即下载失败。可以显示圆角的图像。可以缓存光盘或记忆。 CAN通讯preSS图像。

https://github.com/nostra13/Android-Universal-Image-Loader. It is based on Lazy List(works on same principle). But it has lot of other configurations. I would prefer to use *Universal Image Loader* coz it gives you more configuration options. You can display a error image if downlaod failed. Can display images with rounded corners. Can cache on disc or memory. Can compress image.

在自定义适配器的构造函数

In your custom adapter constructor

  File cacheDir = StorageUtils.getOwnCacheDirectory(a, "your folder");

 // Get singletone instance of ImageLoader
 imageLoader = ImageLoader.getInstance();
 // Create configuration for ImageLoader (all options are optional)
 ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(a)
          // You can pass your own memory cache implementation
         .discCache(new UnlimitedDiscCache(cacheDir)) // You can pass your own disc cache implementation
         .discCacheFileNameGenerator(new HashCodeFileNameGenerator())
         .enableLogging()
         .build();
 // Initialize ImageLoader with created configuration. Do it once.
 imageLoader.init(config);
 options = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.stub_id)//display stub image
.cacheInMemory()
.cacheOnDisc()
.displayer(new RoundedBitmapDisplayer(20))
.build();

在你的getView()

In your getView()

  ImageView image=(ImageView)vi.findViewById(R.id.imageview); 
  imageLoader.displayImage(imageurl, image,options);//provide imageurl, imageview and options

您可以与其他选项进行配置以满足您的需求。

You can configure with other options to suit your needs.

随着延迟加载/通用图像装载机,您可以查看支架的平滑滚动和性能。 <一href="http://developer.android.com/training/improving-layouts/smooth-scrolling.html">http://developer.android.com/training/improving-layouts/smooth-scrolling.html.

Along with lazy loading/Universal Image Loader you can view holder for smooth scrolling and performance. http://developer.android.com/training/improving-layouts/smooth-scrolling.html.

这篇关于什么是LazyList?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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