Android Listview - only load images into items when user stops scrolling

我只是一个虾纸丫 提交于 2019-12-11 04:36:14

问题


When the user scrolls quickly through items, it seems superfluous to start requesting images to populate those items. Afterall, the user is scrolling so fast, they will never be downloaded/shown in time. Is there any kind of method/event that first fires when the user has actually paused scrolling?


回答1:


Try this code to detect scrolling stop :

setOnScrollListener(new OnScrollListener()
{
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) 
    {
        // TODO Auto-generated method stub
    }
    public void onScrollStateChanged(AbsListView view, int scrollState) 
    {
        // TODO Auto-generated method stub
        if(scrollState == 0) 
            Log.i("a", "scrolling stopped...");
    }
});


来源:https://stackoverflow.com/questions/18826465/android-listview-only-load-images-into-items-when-user-stops-scrolling

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