快速滚动的ListView中使用优化或UniversalImageloader使用视图的引用 [英] Fast Scroll In ListView optimizing using UniversalImageloader or using references of Views

查看:110
本文介绍了快速滚动的ListView中使用优化或UniversalImageloader使用视图的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让有点类似Facebook或Instagram的时间表。更接近的Instagram。在图像加载我使用的库UniversalImageLoader。我的每一个ListView项的行可能超过600dp的高度。通常我取5个项目在同一时间。

现在出现的问题是,当滚动快了一点互相替代的影像。由于意见被重用。大约需要3-4秒的图像显示出来,否则错误的图像将在ListView的行显示。

1。如果任何人都可以知道如何优化/修复这个快速滚动ImageOverlap问题
除此以外,
2 - 什么是记录EntireView,让我们在一些的ArrayList,并把它在当前位置说的方式。他指出,有相当多其他的东西发生得,不仅mediaDp被改变。

 如果(convertView == NULL)
    {
        鉴于= inflator.inflate(R.layout.timeline_list_row,父母,假);
        viewHolder.userDp =(RoundedImageView)view.findViewById(R.id.userDp);        viewHolder.mediaDp =(ImageView的)view.findViewById(R.id.imagePostedMedia);        / ************组保持与LayoutInflater ************ /
        view.setTag(viewHolder);
        最后ViewHolder newHolder = viewHolder;    }
    其他
        viewHolder =(ViewHolder)view.getTag();    imageLoader.displayImage(media.imagePath,viewHolder.mediaDp);


解决方案

尝试为ImageView的设置位选项如下:

  DisplayImageOptions选项=新DisplayImageOptions.Builder()
                        .showImageOnLoading(R.drawable.ic_stub)
                        .showImageForEmptyUri(R.drawable.ic_empty)
                        .showImageOnFail(R.drawable.ic_error)
                        .cacheInMemory(真)
                        .cacheOnDisc(真)
                        .considerExifParams(真)
                        。建立();

和现在尝试diplay到的ImageView为

  imageLoader.displayImage(imageUrls [位置],holder.image,期权);

我相信这会工作。

查看code cacheInMemory(真)属性的显示选项是非常重要的。

I am trying to make a TimeLine somewhat similar to Facebook or Instagram. More closer to Instagram. In Images loading i am using library UniversalImageLoader. Each of my ListView item row is probably more than 600dp in height. Usually I am fetching 5 items at a time.

The problem that occurs now is, The images when scroll a little fast replace each other. Since the views are being reused. It takes about 3-4 seconds for images to show up otherwise wrong images will be displayed in listView Row.

1- If anyone can know how to optimise/fix this fast scroll ImageOverlap issue Otherwise, 2- What is the way to record EntireView , let's say in some "ArrayList" and placing it at current position. Noting that there are quite other stuff happening too , not only mediaDp being changed.

    if (convertView == null)
    {
        view = inflator.inflate(R.layout.timeline_list_row, parent, false);
        viewHolder.userDp = (RoundedImageView) view.findViewById(R.id.userDp);

        viewHolder.mediaDp = (ImageView) view.findViewById(R.id.imagePostedMedia);

        /************ Set holder with LayoutInflater ************/
        view.setTag(viewHolder);
        final ViewHolder newHolder = viewHolder;

    }
    else
        viewHolder = (ViewHolder) view.getTag();

    imageLoader.displayImage(media.imagePath, viewHolder.mediaDp);

解决方案

Try setting bitmap options for the imageview as follows.

DisplayImageOptions  options = new DisplayImageOptions.Builder()
                        .showImageOnLoading(R.drawable.ic_stub)
                        .showImageForEmptyUri(R.drawable.ic_empty)
                        .showImageOnFail(R.drawable.ic_error)
                        .cacheInMemory(true)
                        .cacheOnDisc(true)
                        .considerExifParams(true)
                        .build();

and now try diplay to imageview as

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

I am sure this will work.

See the code cacheInMemory(true) property for display options is important.

这篇关于快速滚动的ListView中使用优化或UniversalImageloader使用视图的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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