如何以百分比显示所有文件的进度



如何实现一个进度条,该进度条将以0%到100%(所有文件(的百分比显示所有文件的进度下载。这是我的异步的样子:

    public class DownloadFileFromFTP extends AsyncTask<String, Void, String> {
        private Context context;
        private ProgressDialog progressDialog;
        public DownloadFileFromFTP(Context context) {
            this.context = context;
            this.progressDialog = new ProgressDialog(MyActivity.this);
            this.progressDialog.setCancelable(false);
         this.progressDialog.setMessage("Please wait...");
            this.progressDialog.show();
        }
        protected void onPreExecute() {
        }
        @Override
        protected String doInBackground(String... arg0) {
    //code to list ftp files
            return null;
        }
        @Override
        protected void onProgressUpdate(Void... values) {
            super.onProgressUpdate(values);
        }
        @Override
        protected void onPostExecute(String result) {
            if (this.progressDialog != null) {
                this.progressDialog.dismiss();
            }
        }
}

它应该是

   @Override
    protected void onProgressUpdate(Void... values) {
      this.progressDialog.setProgress(Integer.parseInt(values[0]));
    }

相关内容

  • 没有找到相关文章

最新更新