一个因为粗心的Bug

/**
* 数据绑定,分页显示
*/
private void updataMenu(final EditText search)
{
if(listwz==null)
{
return;
} pageID =0;
listwz.setAdapter(null);
FilterArray = new JSONArray();
FilterArray = usedatabase.WzArray(search.getText().toString(), pageID,WzLbID);
// pageID = 1; //Bug 少查10条数据,但不影响速查
wzadapter = new WzAdapter(context, FilterArray,search);
listwz.setAdapter(wzadapter);
listwz.setOnScrollListener(new OnScrollListener() {
int lastitem = 0;
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
// TODO Auto-generated method stub
if(scrollState == OnScrollListener.SCROLL_STATE_IDLE && listwz.getCount()-lastitem<1)
{
if(WzLbID.equals(""))
{
pageID +=1;
//把原来的加到一个新的Array里面
NewArray = new JSONArray();
NewArray = usedatabase.WzArray(search.getText().toString(), pageID,WzLbID);
try {
for(int i=0;i<NewArray.length();i++)
{
JSONObject item = (JSONObject)NewArray.get(i);
FilterArray.put(item);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int currentPostition = listwz.getFirstVisiblePosition();
WzAdapter adapter = new WzAdapter(context, FilterArray,search);
listwz.setAdapter(adapter);
listwz.setSelectionFromTop(currentPostition+1, 0);
}
else
{
if(usedatabase.WzArray(search.getText().toString(), pageID,WzLbID).length()>FilterArray.length())
{
pageID +=1;
//把原来的加到一个新的Array里面
NewArray = new JSONArray();
NewArray = usedatabase.WzArray(search.getText().toString(), pageID,WzLbID);
try {
for(int i=0;i<NewArray.length();i++)
{
JSONObject item = (JSONObject)NewArray.get(i);
FilterArray.put(item);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int currentPostition = listwz.getFirstVisiblePosition();
WzAdapter adapter = new WzAdapter(context, FilterArray,search);
listwz.setAdapter(adapter);
listwz.setSelectionFromTop(currentPostition+1, 0);
}
}
}
} @Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
// TODO Auto-generated method stub
lastitem = visibleItemCount+firstVisibleItem; }
});
}

在按类别分页查询时候,默认为从10-0开始,查过一次后加了1,然后会照成10-10这10条数据查不出来,在大数据时候这10条数据很难发现,今天一个测试库只有26条数据,总是就加载16条数据,百思不得其解,检查代码才发现,真是粗心。

上一篇:转】从源代码剖析Mahout推荐引擎


下一篇:前端开发规范之命名规范、html规范、css规范、js规范