List-view Lazy Load android

时间:2012-02-16 10:46:28

标签: android

我需要在自定义列表视图中防止延迟加载。所以我发现scrollview onscroll listner是有帮助的,我已经尝试过但没有成功实现这个功能。

代码::

lviewAdapter = new ListViewAdapter(SaxParser2.this, Arr_ActivityName_fack, Arr_AudioScript_fack,Arr_RequestID_fack,Arr_FolderPath_fack,Arr_RequestTo_fack);
                         lview.setOnScrollListener(SaxParser2.this);
                         lview.setAdapter(lviewAdapter);




@Override
    public void onScroll(AbsListView view, int firstVisibleItem,
            int visibleItemCount, int totalItemCount) {
        // TODO Auto-generated method stub
        if (firstVisibleItem + visibleItemCount == totalItemCount) {
            generateEntries();

            lviewAdapter.notifyDataSetChanged();
        }
    }

    private void generateEntries() {
        for (int x = counter; x < counter + 10; x++) {
            /*
             * Custom temp = new Custom("Big" + x,"Small" + x); fetch.add(temp);
             */
            Arr_ActivityName_fack[x] = Arr_ActivityName[x];
            Arr_AudioScript_fack[x] = Arr_AudioScript[x];
            Arr_RequestID_fack[x] = Arr_RequestID[x];
            Arr_FolderPath_fack[x] = Arr_FolderPath[x];
            Arr_RequestTo_fack[x] = Arr_RequestTo[x];
        }
        counter += 10;
    }

    @Override
    public void onScrollStateChanged(AbsListView arg0, int arg1) {
        // TODO Auto-generated method stub

    }
}

问题是当我运行app时,没有获得任何记录。

0 个答案:

没有答案