ListView滚动加载(类似Android Market的列表)
1.滚动加载
listView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
//滚动条滚到最底部,加载余下的元素
if (firstVisibleItem + visibleItemCount == totalItemCount)
loadRemnantListItem();
}
});
private void loadRemnantListItem() {//滚到加载余下的数据
//动态的改变listAdapter.getCount()的返回值
//调用listAdapter.notifyDataSetChanged();更新数据
}