android - 使用Volley加载数据时进度条冻结

时间:2014-06-10 04:59:03

标签: android progress-bar android-volley

我正在使用仅在使用Volley加载数据时显示的进度条,但我的进度条会冻结直到数据加载。请帮忙。以下是正常工作的代码,除了进度条冻结。

 private class GetValue extends AsyncTask<String, String, String> {

    ProgressDialog progressDialog=null;

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        progressDialog = ProgressDialog.show(context, "Loading Data...", "Please Wait");

    }

    @Override
    protected void onPostExecute(String result) {

        super.onPostExecute(result);
        progressDialog.dismiss();
    }

    @Override
    protected String doInBackground(String... params) {
        // TODO Auto-generated method stub
        assignValues(mnyr ,mnyr1);          
        return null;
    }
}

  private void assignValues(String s1, String s2) {
    // TODO Auto-generated method stub
    //C.progressStart(context, "Loading Data...", "Please Wait");
    final String s = s1;
    final List<List<String>> values = new ArrayList<List<String>>();
    datas = new ArrayList<CustomData>();
    RequestQueue queue = Volley.newRequestQueue(this);
    String val = s1 + "/" + s2;
    final StringRequest request = new StringRequest(Method.GET, C.EVENTS + val,
            new Listener<String>() {

                @Override
                public void onResponse(String arg0) {
                    // TODO Auto-generated method stub
                    JsonParser parent = new JsonParser(arg0);
                    if(parent.getValue("data") == null){
                    int length = parent.getArrLength(arg0);

1 个答案:

答案 0 :(得分:1)

ProgressDialog progressDialog=null; // inside asynTask method

 @Override
    protected void onPreExecute() {
        super.onPreExecute();
        progressDialog = ProgressDialog.show(uractivity.this, "Wait", "Downloading...");

    }

 @Override
    protected void onPostExecute(String result) {

        super.onPostExecute(result);
progressDialog.dismiss();
    }