Fast Scroll In ListView optimizing using UniversalImageloader or using references of Views

放肆的年华 提交于 2019-12-23 03:14:21

问题


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);

回答1:


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.




回答2:


I have answered a similar question (like this) before, please take a reference to this Answer :
How can I delay the loading of views in my list adapter while the user is scrolling fast
I hope this helps.



来源:https://stackoverflow.com/questions/21340127/fast-scroll-in-listview-optimizing-using-universalimageloader-or-using-reference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!