2016-12-15 68 views
0

在我的片段中,ParseQuery成功查詢如下:檢查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){ 




          } 


         } 


        } 
       }); 

但是,如果連接速度很慢,只有背景是可見的,直到它查詢。如何在加載分析查詢時顯示加載符號?

回答

0

您需要在執行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) { 
 

 

 

 

 
     } 
 

 

 
    } 
 

 

 
    } 
 
});

好運。