如何在线加载图像时设置进度微调器?

时间:2013-02-18 15:49:23

标签: android android-progressbar

在我的应用中,我使用AsyncTask从网址加载图片,而图片加载时,ImageView为空。因此,在加载时,如何在那里显示微调器/加载进度?

1 个答案:

答案 0 :(得分:0)

以下是示例代码:

public class BackgroundAsyncTask extends AsyncTask<Void, Void, Void> {

  private ProgressDialog progressdialog;

 @Override
protected void onPreExecute(){ 
   super.onPreExecute();
        progressdialog= new ProgressDialog(yourContext);
        progressdialog.setMessage("Downloading Image");
        progressdialog.show();    
}

@Override
  protected Void doInBackground(Void... params) {
   //Do whatever you have to here
  }


  @Override
protected void onPostExecute(String result){
   super.onPostExecute(result);
        progressdialog.dismiss();
}
}