我现在是使用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();
}
}
}
解决方案 »
- main.xml的schemas约束中提供的地址是否是确定的文档约束?
- 想问个问题,android能把整个布局缩放吗?
- 如何调试这个错误,错误信息如下
- Activity生命周期问题。
- 关于android 内核版本选择的问题++++
- listview嵌套多个edittext,点击edittext,软键盘挡住界面的问题
- wallpaper横竖屏切换问题
- 写了一个群发短信App,谜之报错NullPointerException。求解……(附有源码)
- 怎么让Service不被kill掉或能自动重启
- 使用retrofit遇到的问题
- Android里怎么获取WAP Push类型信息是由哪个短信中心(SMSC)发来?
- 关于资源R.string的问题。求助各位大侠。
2、adapter的更新