0

在 Android 应用程序中使用 ksoap 下载数据时,如何在水平进度条中显示进度?

在这里,我使用 AsyncTask 从服务器获取数据。同时我需要根据传输的数据与要传输的数据显示水平进度条的进度。

private class SyncIncoData extends AsyncTask<String, Void, String> {
        ProgressBar pb;
        LinearLayout all;
        @Override
        protected String doInBackground(String... urls) {
            try {
                incodata=si.GetSoapData();
                db=new SqlConnector(con);
                datacheckerInco(incodata);
            } catch (Exception e) {

                e.printStackTrace();
            }

            return null;
        }

        @Override
        protected void onPreExecute() {
            // TODO Auto-generated method stub
            super.onPreExecute();
            all=(LinearLayout)findViewById(R.id.linearLayoutall);
            all.setEnabled(false);
            pb=(ProgressBar)findViewById(R.id.progressBarsync4);
            pb.setVisibility(View.VISIBLE);
            back=false;
            saleto.setClickable(false);
            shipto.setClickable(false);
            mate.setClickable(false);
            inco.setClickable(false);
            off.setClickable(false);
            tv4.setText("Synchronizing");
            //im4.setVisibility(View.INVISIBLE);
        }

        @Override
        protected void onPostExecute(String result) {
            all=(LinearLayout)findViewById(R.id.linearLayoutall);
            all.setEnabled(true);
            pb=(ProgressBar)findViewById(R.id.progressBarsync4);
            pb.setVisibility(View.INVISIBLE);
            back=true;
            saleto.setClickable(true);
            shipto.setClickable(true);
            mate.setClickable(true);
            inco.setClickable(true);
            off.setClickable(true);
            tv4.setText("Completed");
            //im4.setVisibility(View.VISIBLE);
        }
    }
4

1 回答 1

0

看看这个:https ://sites.google.com/site/androidhowto/how-to-1/create-a-custom-progress-bar-using-asynctask

于 2012-04-03T10:46:38.747 回答