非常简单。将请求对象添加到队列后,启动进度对话框。
//add the request to the queuerq.add(request);//initialize the progress dialog and show itprogressDialog = new ProgressDialog(getActivity());progressDialog.setMessage("Fetching The File....");progressDialog.show();从服务器收到响应后,请关闭该对话框。
StringRequest postReq = new StringRequest(Request.Method.POST, "http://httpbin.org/post", new Response.Listener<String>() { @Override public void onResponse(String response) { tv.setText(response); // We set the response data in the TextView progressDialog.dismiss(); }}, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e(“Volly Error”,”Error: ”+error.getLocalizedMessage()); progressDialog.dismiss(); }});


