0

我的目标:下载许多图像并允许用户看似无休止地滚动它们。

我的问题:当用户滚动时,我无法有效地设置和取消设置图像以节省内存。我是 android 新手,所以我确信有比我正在做的更好的方法。

我目前的方法:这只是一个大纲

//I have a listener setup for the scroll 
 onScrollChanged(ScrollViewExt scrollView, int x, int y, int oldx, int oldy){
//if the user has scrolled 1000 pix and there is currently no other updating thread running
      if(((y%1000==0)||(y%1000>990))&&!updating){
             updating=true;
             AsyncTask<String, Void, Void> update = new   UpdateViews().execute(y+"");
    }
 }
//updateviews essentially iterates though all my views and calls a method in each one that returns getLocationOnScreen().  
// This in turn is used to determine if the view is far away enough from the scroll to have its image removed or has come back to the area and is added to an appropriate array-list as to be altered later on the UI thread
//everything is saved to a array-list and the views are updated on the onPostExecute() because they have to be done on the main thread

现在我知道我写的内容存在一些问题,因为它只是初步代码,但会导致 ui 滞后并偶尔崩溃。我正在寻找如何有效地做到这一点的想法。

4

1 回答 1

0

使用了具有大量自定义功能的列表视图

于 2013-05-18T07:04:30.630 回答