检查 ParseQuery 是否正在加载
Check if ParseQuery is loading
在我的Fragment中,ParseQuery成功查询如下:
comments = new ParseQuery<ParseObject>("CommentItem");
comments.setLimit(99);
comments.whereEqualTo("parentUser", feedUserName);
comments.whereEqualTo("parentFeed", feedItem);
comments.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> mobjects, ParseException e) {
if(e == null){
for(ParseObject object : objects){
}
}
}
});
但是,如果连接速度较慢,则在查询之前只能看到背景。如何在加载解析查询时显示加载符号?
您需要在执行 findInBackground 之前显示进度对话框并在回调中关闭它。
所以您的代码应该如下所示:
comments = new ParseQuery < ParseObject > ("CommentItem");
comments.setLimit(99);
comments.whereEqualTo("parentUser", feedUserName);
comments.whereEqualTo("parentFeed", feedItem);
// show progres dialog
final ProgressDialog myDialog = ProgressDialog.show(this, "Loading...","Loading Results...", true);
comments.findInBackground(new FindCallback < ParseObject > () {@
Override
public void done(List < ParseObject > mobjects, ParseException e) {
myDialog.dismiss(); // remove progress dialog on finish
if (e == null) {
for (ParseObject object: objects) {
}
}
}
});
祝你好运。
在我的Fragment中,ParseQuery成功查询如下:
comments = new ParseQuery<ParseObject>("CommentItem");
comments.setLimit(99);
comments.whereEqualTo("parentUser", feedUserName);
comments.whereEqualTo("parentFeed", feedItem);
comments.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> mobjects, ParseException e) {
if(e == null){
for(ParseObject object : objects){
}
}
}
});
但是,如果连接速度较慢,则在查询之前只能看到背景。如何在加载解析查询时显示加载符号?
您需要在执行 findInBackground 之前显示进度对话框并在回调中关闭它。 所以您的代码应该如下所示:
comments = new ParseQuery < ParseObject > ("CommentItem");
comments.setLimit(99);
comments.whereEqualTo("parentUser", feedUserName);
comments.whereEqualTo("parentFeed", feedItem);
// show progres dialog
final ProgressDialog myDialog = ProgressDialog.show(this, "Loading...","Loading Results...", true);
comments.findInBackground(new FindCallback < ParseObject > () {@
Override
public void done(List < ParseObject > mobjects, ParseException e) {
myDialog.dismiss(); // remove progress dialog on finish
if (e == null) {
for (ParseObject object: objects) {
}
}
}
});
祝你好运。