本帖最後由 xjxuvup 於 2013-6-3 11:19 編輯
- new AsyncTask<Context, Void, Void>(){
- @Override
- imageLoader=new ImageLoader(getApplicationContext()); //假如用以下這兩行,就不 會出現我說的問題,但是跑出來的圖片會模糊掉。
- imageLoader.DisplayImage(ne.picture01, holder.image);
- } catch (Exception e){
-
- }
- return null;
- }
-
- }.execute();
複製代碼 如果用下面這段,就會出現背景圖跑出來的問題- new AsyncTask<Context, Void, Void>(){
- @Override
- protected Void doInBackground(Context... arg0) {
- // TODO Auto-generated method stub
- Bitmap bitmap = null;
- Drawable drawable;
- try{
- URL url = new URL(ne.picture01);
- HttpURLConnection connection = (HttpURLConnection)url.openConnection();
- connection.setDoInput(true);
- connection.connect();
- InputStream inputStream = connection.getInputStream();
- bitmap = BitmapFactory.decodeStream(inputStream);
- inputStream.close();
- drawable = new BitmapDrawable(bitmap);
- holder.image.setBackgroundDrawable(drawable);
- } catch (Exception e){
-
- }
- return null;
- }
-
- }.execute();
複製代碼 |