我有一个从互联网加载图像的图像视图。我正在从网络加载图像并使用异步任务将其转换为位图图像。我想在我的图像视图中显示一个静态图像,并在图像加载时在图像视图顶部有一个进度微调器。问题是我的 xml 中有进度微调器,我无法在异步任务中使用它,而且我不知道如何使进度微调器在图像视图中也可见。我该怎么做呢?这是我的异步任务类:
public class LoadImage extends AsyncTask<Void, Void, Bitmap>{
    Context callingContext = null;
    ImageView view;
    String b = null;
    ListView lv;
    ProgressDialog p;
    public LoadImage(Context c, ImageView view, String b){
        this.view = view;
        this.b = b;
        this.callingContext = c;
    }
    @Override
    protected void onPreExecute() {
        // TODO Auto-generated method stub
        super.onPreExecute();
    //  p = (ProgressDialog) findViewById(R.id.progressBar1);
        p = ProgressDialog.show(callingContext, "Loading Events", "Retrieving data from server, please wait...", true);
    }
    public Bitmap getBit(String data){
        Bitmap bitmap;
        BitmapFactory.Options bmOptions;
        bmOptions = new BitmapFactory.Options();
        bmOptions.inJustDecodeBounds = true;
        //from web
        try {
            bitmap=null;
            InputStream is=new URL(data).openStream();
            BitmapFactory.decodeStream(is, null, bmOptions);
            is.close();
            BitmapFactory.Options o2 = new BitmapFactory.Options();
            o2.inSampleSize = 20;
            is = new URL(data).openStream();
            bitmap = BitmapFactory.decodeStream(is, null, o2);
            is.close();
            return bitmap;
        } catch (Exception ex){
           ex.printStackTrace();
           return null;
        }
    }
    @Override
    protected Bitmap doInBackground(String... arg0) {
        // TODO Auto-generated method stub  
        Bitmap b = null;    
        URL imageUrl = null;
        b = getBit(this.b);
            return b;  
    }
    @Override
    protected void onPostExecute(Bitmap result) {
        // TODO Auto-generated method stub
        super.onPostExecute(result);
        if(result == null)
            view.setImageResource(R.drawable.ic_launcher);
        p.dismiss();
    }   
}