本文介绍了Android的凌空抽射得到回调时的所有请求完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的凌空排队一系列请求。我显示进度对话框给用户,当这些请求发生。有没有一种方法可以检查当所有这些请求都完成了。这就是我想要的。
I am using volley to queue a series of requests. I am showing a progress dialog to the user when these requests are happening. Is there a way I can check when all these requests are finished.This is what I want.
//Show progress bar
for(int i=0;i<size;i++)
{
//create request and add the request
requestQueue.add(request);
}
// When last request finsihes dismiss progres bar
有没有办法解决这个问题。
Is there a solution to this problem.
推荐答案
您可以保持在一个成员变量申请总数:
You can keep the total number of requests in a member variable :
int pendingRequests = 0;
//...
for(int i=0;i<size;i++)
{
requestQueue.add(request);
pendingRequests++;
}
然后每个请求完成你递减计数器,如果达到0,你知道,所有的请求都完成的时间。
Then each time a request finishes you decrement the counter, and if it reaches 0, you know that all requests are done.
这篇关于Android的凌空抽射得到回调时的所有请求完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!