ListView scrolling using UniversalImageDownloader not smooth

后端 未结 2 1330
星月不相逢
星月不相逢 2021-02-10 13:58

I am using a ListView containing images. These images are loaded from the Internet inside the adapter. Therefore I am using the UniversalImageDownloader.

<
2条回答
  •  清歌不尽
    2021-02-10 14:53

    I had the same issue with image downloading. I solved it by setting delayBeforeLoading(1000) in my DisplayImageOptions. It is needed to start downloading when user stop fling.

    so try to replace your getDisplayOptions method with this

     public static DisplayImageOptions getDisplayOptions() {
    
         DisplayImageOptions options = new DisplayImageOptions.Builder()
        .showImageForEmptyUri(R.drawable.error)
        .showImageOnFail(R.drawable.error)
        .delayBeforeLoading(1000) 
        .resetViewBeforeLoading(false)  // default
        .cacheInMemory(true) // default
        .cacheOnDisc(true) // default
        .build();
    
        return options;
    }
    

    Documentation also recommends to use this code to avoid grid/list view scroll lags

    boolean pauseOnScroll = false; // or true
    boolean pauseOnFling = true; // or false
    PauseOnScrollListener listener = new PauseOnScrollListener(imageLoader, pauseOnScroll, pauseOnFling);
    listView.setOnScrollListener(listener);
    

    You can read it here (the last item of "Useful Info" list)

    So you can use one of this methods

提交回复
热议问题