android在滚动的时候怎么刷新listview
1个回答
2015-02-06 · 知道合伙人数码行家
huanglenzhi
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:117538
获赞数:517165
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。
向TA提问 私信TA
关注
展开全部
在做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");
}
public abstract void onScroll (AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
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
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
在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 1
Callback 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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询