android中ListView滚动刷新
2011-09-06 17:06
375 查看
在做ListView加载数据时如果数据量大的话会造成加载时间过长而卡屏,所以为了解决这个问题,查看了SDK,
在OnScrollListener中有两个方法
只要重写这两个方法就可以实现滚动加载,例如:
public void onScroll(AbsListView v, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
lastItem = firstVisibleItem + visibleItemCount - 1;
if (adapter.count == lastItem) {
adapter.count += 10;
adapter.notifyDataSetChanged();
}
}
public void onScrollStateChanged(AbsListView view, int scrollState) {
// TODO Auto-generated method stub
Log.i("onScrollStateChanged", "onScrollStateChanged");
}
Since: API Level 1
Callback method to be invoked when the list or grid has been scrolled. This will be called after the scroll has completed
Parameters
Since: API Level 1
Callback method to be invoked while the list view or grid view is being scrolled. If the view is being scrolled, this method will be called before the next frame of the scroll is rendered. In particular, it will be called before any calls to
Parameters
在OnScrollListener中有两个方法
只要重写这两个方法就可以实现滚动加载,例如:
public void onScroll(AbsListView v, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
lastItem = firstVisibleItem + visibleItemCount - 1;
if (adapter.count == lastItem) {
adapter.count += 10;
adapter.notifyDataSetChanged();
}
}
public void onScrollStateChanged(AbsListView view, int scrollState) {
// TODO Auto-generated method stub
Log.i("onScrollStateChanged", "onScrollStateChanged");
}
public abstract void onScroll (AbsListView view,
int firstVisibleItem, int visibleItemCount, int totalItemCount)
Since: API Level 1Callback method to be invoked when the list or grid has been scrolled. This will be called after the scroll has completed
Parameters
view | The view whose scroll state is being reported |
---|---|
firstVisibleItem | the index of the first visible cell (ignore if visibleItemCount == 0) |
visibleItemCount | the number of visible cells |
totalItemCount | the number of items in the list adaptor |
public abstract void onScrollStateChanged (AbsListView view,
int scrollState)
Since: API Level 1Callback method to be invoked while the list view or grid view is being scrolled. If the view is being scrolled, this method will be called before the next frame of the scroll is rendered. In particular, it will be called before any calls to
getView(int, View, ViewGroup).
Parameters
view | The view whose scroll state is being reported |
---|---|
scrollState | The current scroll state. One of SCROLL_STATE_IDLE, SCROLL_STATE_TOUCH_SCROLLor SCROLL_STATE_IDLE. |
相关文章推荐
- Android ListView嵌套ListView、滚动刷新数据
- android中ListView滚动刷新
- android testview + listview 整体滚动刷新
- android中ListView滚动刷新
- Android 高仿新浪微博底部导航栏,实现双击首页Tab,页面的ListView滚动、刷新
- Android 高仿新浪微博底部导航栏,实现双击首页Tab,页面的ListView滚动、刷新
- Android PullToRefreshScrollview+Listview 刷新界面的时候滚动到顶部
- ------------------Android中对GridView, ListView等滚动控件的Touch事件onInterceptTouchEvent,onTouchEvent了解
- Android中设置ListView内容刷新问题
- Android的ListView控件滚动时背景问题
- Android弹性listview滚动
- Android 记录和恢复ListView滚动的位置的两种方法
- android记录和恢复ListView滚动的位置
- Android中设置onTouch事件后listview产生点击变长按、不能滚动的的怪异现象
- android listview 实现从数据库读取已读功能,服务器通知增加,刷新listview
- ListView 滚动翻页/滚动加载(类似Android Market的列表)
- android开发之记录ListView滚动位置
- Android ScrollView+ListView 会滚动到ListView位置
- Android最佳实践性能(三)提高性能布局(使ListView滚动流畅)
- android listview刷新