0
嗯,我不那么具体和明确的称号(试图太难为它)道歉,所以我有这个功能控制自动功能手动
public void fetchData(){
dataQuery.setPageSize(10); // fetch 10 items per request
final boolean[] firstResponse = {true};
final CountDownLatch latch = new CountDownLatch(1);
// a callback of fetching data from server
Backendless.Data.of(Note.class).find(dataQuery, new AsyncCallback<BackendlessCollection<Note>>() {
@Override
public void handleResponse(BackendlessCollection<Note> notes) { // here we have the response of request
/// loop for requesting for items until all of them is fetched//////
if(firstResponse[0])
{
firstResponse[0] =false;
}
int size = notes.getCurrentPage().size();
if(size > 0)
notes.nextPage(this);
else
latch.countDown();
//////////////////////////////////
/// do whatever I want with the fetched data
}
@Override
public void handleFault(BackendlessFault fault) {// here we have the error of request
swipeToReload.setRefreshing(false);
Toast.makeText(getContext(), "" + fault.getMessage(), Toast.LENGTH_LONG).show();
}
});
}
所以现在上面的功能是在获取10 items
每个请求循环和这个循环运行,直到所有的数据检索,我想要的是让这个循环手动运行(在按钮点击我想加载前10项,然后而不是再次请求我希望它手动工作,获取下一个按钮上的10个项目)如果有人能指导我正确的方向,那么它会对我很有帮助
非常感谢您的回复,请您解释一下'dataQuery.setOffset(offset)'? –
从服务器加载的所有对象都按顺序组织。第一个对象具有偏移量0,第二个具有偏移量1,依此类推。当您使用dataQuery.setOffset设置偏移量时,您指示服务器从指定的偏移量加载对象的下一个“页面”。 –