首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

lisTView分页展示

2012-09-10 
lisTView分页显示两种方法 或者根本上一种:就是当达到一页的最后一个时 在getView() 判断 if position is

lisTView分页显示

两种方法 或者根本上一种:

就是当达到一页的最后一个时 在getView() 判断 if position is >= the size of ListAdapter.getCount().

然后就显示另一页

其实也可以

public static final int SCROLLING_OFFSET = 5;?
// ...?
private final ArrayList<T> items = new ArrayList<T>();?
// ...?
if (SCROLLING_OFFSET == items.size() - position) {?
? ? if (hasNextPage()) {?
? ? ? ? addNextPage();?
? ? }?
}?
?
private boolean hasNextPage() {?
? ? // basically calculates whether the last 2 pages contained the same # of items?
}?
?
private void addNextPage() {?
? ? // show spinner?
? ? // fetch next page in a background thread?
? ? // add to items?
? ? notifyDataSetChanged();?
}?

热点排行