我看过下面的帖子: Working POST Multipart Request with Volley and without HttpEntity
我的问题是如何包含进度条。
进度条有一些解决方案,但它们都使用 HttpClient,我想避免使用它,因为它已被弃用。
我只是想不出如何将两者结合起来。
编辑:
我正在寻找一个显示百分比的进度条,而不仅仅是一个连续的圆圈。 我想要的带有栏的示例出现在此处但使用的是 HTTPClient: How to send a “multipart/form-data” POST in Android with Volley
最佳答案
如果我没有误解问题的话,这对我来说似乎很简单。你为什么不开始显示你的进度条(最好是不确定的),当你的请求成功或失败时,你就停止进度条。
像这样的:-
myRequest(){
//Start Showing your progress bar here
showProgressBar();
JsonObjectRequest myRequest =
new JsonObjectRequest(Request.Method.GET, URL,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
//Hide progress bar here
hideProgressDialog();
//TODO: I forgot what to do
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
//Hide progress bar here
hideProgressDialog();
}
});
queue.add(myRequest);
}
希望对您有所帮助:)
关于android - 在不使用 HttpEntity 的情况下使用 Volley 发布 Multipart 并取得进展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35705694/