实现OnScrollListener
06000
并在listView中设置OnScrollListener
listView.setOnScrollListener(NewsCategoryDC.this);
您可以获取第一个和最后一个可见行
@Override
public void onScroll(AbsListView view, int firstVisibleItem,int visibleItemCount, int totalItemCount) {
firstVisibleRow = listView.getFirstVisiblePosition();
lastVisibleRow = listView.getLastVisiblePosition();
/*Now you get the first and last visible rows, and you easily get the rows from first to last visible row and allocate resources to visible rows or deallocate resources to rows except visible rows..,.*/
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {}
尝试这个..,。
如果您有其他最好的方式,请发表,这是非常有用和好的问题..,。
谢谢..,。
编辑……………………….
在onScroll()方法中添加代码
@Override
public void onScroll(AbsListView view, int firstVisibleItem,int visibleItemCount, int totalItemCount) {
int firstVisibleRow = listView.getFirstVisiblePosition();
int lastVisibleRow = listView.getLastVisiblePosition();
for(int i=firstVisibleRow;i<=lastVisibleRow;i++)
{
//Write your code here(allocation/deallocation/store in array etc.)
System.out.println(i + "=" + listView.getItemAtPosition(i));
}
}