如何从 Parse.com 检索超过 1000 行? [英] How to retrieve more than 1000 rows from Parse.com?
本文介绍了如何从 Parse.com 检索超过 1000 行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在使用 Parse 来检索列表视图的数据.不幸的是,默认情况下,他们将请求限制为 100,最大为 1000.我的班级最高 1000 分.我在网上找到了一个链接,它显示了一种在 iOS 上执行此操作的方法,但您将如何在 Android 上执行此操作?网页链接
I have been using Parse to retrieve a data for a list view. Unfortunately they limit requests to 100 by default to a 1000 max. I have well over that 1000 max in my class. I found a link on the web which shows a way to do it on iOS but how would you do it on Android? Web Link
我目前正在循环中将所有数据添加到数组列表中,直到所有项目都完成(100)然后将它们添加到列表中
I am currently adding all the data into a arraylist in a loop until all items are complete (100) then adding them to the list
推荐答案
我已经想出了如何实现我的目标:
I have figured out how to achieve my goal:
声明全局变量
private static List<ParseObject>allObjects = new ArrayList<ParseObject>();
创建查询
final ParseQuery parseQuery = new ParseQuery("Objects");
parseQuery.setLimit(1000);
parseQuery.findInBackground(getAllObjects());
查询回调
int skip=0;
FindCallback getAllObjects(){
return new FindCallback(){
public void done(List<ParseObject> objects, ParseException e) {
if (e == null) {
allObjects.addAll(objects);
int limit =1000;
if (objects.size() == limit){
skip = skip + limit;
ParseQuery query = new ParseQuery("Objects");
query.setSkip(skip);
query.setLimit(limit);
query.findInBackground(getAllObjects());
}
//We have a full PokeDex
else {
//USE FULL DATA AS INTENDED
}
}
};
}
这篇关于如何从 Parse.com 检索超过 1000 行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文