我现在是使用onScrollListener滚动事件进行分页显示。可是这样永远都达不到我要的效果。我想界面显示5条就从数据库取0-5条。这样取。可惜没思路。请教高手帮忙分析。
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
lastItem = firstVisibleItem+visibleItemCount;
if(lastItem==totalItemCount){
if(adapter.count<=scenicList.size()){
adapter.count+=4;
adapter.notifyDataSetChanged();
lv_m_scenicList.setSelection(lastItem);
int currentPage=adapter.count/4;
Toast.makeText(getApplicationContext(), "第"+currentPage+"页", Toast.LENGTH_LONG).show();
}
}
//System.out.println("latstItem:"+lastItem);
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
if(lastItem == adapter.count && scrollState == OnScrollListener.SCROLL_STATE_IDLE)
{
if(adapter.count<=scenicList.size()){
adapter.count+=4;
System.out.println(adapter.getCount());
adapter.notifyDataSetChanged();
int currentPage=adapter.count/4;
Toast.makeText(getApplicationContext(), "第"+currentPage+"页", Toast.LENGTH_LONG).show();
}
}
}
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
lastItem = firstVisibleItem+visibleItemCount;
if(lastItem==totalItemCount){
if(adapter.count<=scenicList.size()){
adapter.count+=4;
adapter.notifyDataSetChanged();
lv_m_scenicList.setSelection(lastItem);
int currentPage=adapter.count/4;
Toast.makeText(getApplicationContext(), "第"+currentPage+"页", Toast.LENGTH_LONG).show();
}
}
//System.out.println("latstItem:"+lastItem);
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
if(lastItem == adapter.count && scrollState == OnScrollListener.SCROLL_STATE_IDLE)
{
if(adapter.count<=scenicList.size()){
adapter.count+=4;
System.out.println(adapter.getCount());
adapter.notifyDataSetChanged();
int currentPage=adapter.count/4;
Toast.makeText(getApplicationContext(), "第"+currentPage+"页", Toast.LENGTH_LONG).show();
}
}
}
解决方案 »
- Andriod中怎样设置WebView显示内容的大小?
- Android开发环境的搭建(jdk+eclipse+android sdk)
- 在Cygwin下能不能使用Android NDK包里面的ndk-gdb命令对so库文件进行调试?
- git 工具管理开发代码
- android 关于获取相册中图片的路径
- 更换布局问题(android)
- android退出程序???
- android数据库主键自增,怎么做?
- android service服务在应用程序管理中显示的是使用中还是缓存中问题
- android如何在软件盘没出现的情况下获取它的高度
- Android里怎么获取WAP Push类型信息是由哪个短信中心(SMSC)发来?
- 关于资源R.string的问题。求助各位大侠。
2、adapter的更新