我有经典的 AsyncTask 来加载图像:
private class DownloadImageTask extends AsyncTask<String,Void,Bitmap> {
Bitmap bitmap = null;
@Override
protected Bitmap doInBackground(String... str) {
try{
InputStream in = new java.net.URL(picture).openStream();
bitmap = BitmapFactory.decodeStream(new SanInputStream(in));
//viewPicture.setImageBitmap(bitmap);
viewPicture.setBackgroundDrawable(new BitmapDrawable(bitmap));
}
catch(Exception e){
e.printStackTrace();
}
return bitmap;
}
}
但是图像的加载时间很长。当我开始此活动时,除了图像之外的所有内容都已加载,仅在等待一秒钟后我才能看到它。问题是什么?