在我的应用中,我使用AsyncTask
从网址加载图片,而图片加载时,ImageView
为空。因此,在加载时,如何在那里显示微调器/加载进度?
答案 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();
}
}