마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

JSON파싱후 리스트뷰 Imageview에 파일 넣는거 질문이요~

0 추천

제목 그대로 파싱한 후 리스트뷰안의 이미지뷰에 서버에서 받은 이미지를 넣어야 하는데..

리스트뷰 목록이 3개가 add되었다 가정하고 첫번째 이미지뷰에는 이미지가 잘 들어갑니다.

근데 2-3번째 이미지는 못받아오고 있어요

소스같이 올리니 도움 부탁드려요

if (file1 != null && file1.length() > 0) {
new GetBitmapTask_Three(MyAdapter_one.image_three_two, file1).execute();
}


public class GetBitmapTask_Three extends AsyncTask<Void, Void, Bitmap> {
	private String mUrl;		
        public GetBitmapTask_Three(ImageView imageView, String url) {	
	mUrl = url;
	}
		
@Override
protected Bitmap doInBackground(Void... params) {
	HttpURLConnection connection = null;
	InputStream is = null;
	Bitmap retBitmap = null;

	try {
	Log.e("---------------", mUrl);
	URL imgUrl = new URL(mUrl);
	connection = (HttpURLConnection) imgUrl.openConnection();
	connection.setDoInput(true);
	connection.connect();
	is = connection.getInputStream();
	retBitmap = BitmapFactory.decodeStream(is);

	} catch (Exception e) {
	                        e.printStackTrace();
				return null;
			        } finally {
				            if (connection != null) {
					    connection.disconnect();
				            }
			        }
			        return retBitmap;
	}

@Override
protected void onPostExecute(Bitmap bitmap) {
if (MyAdapter_one.image_three_two != null) {
MyAdapter_one.image_three_two.setScaleType(ImageView.ScaleType.FIT_XY);
MyAdapter_one.image_three_two.setImageBitmap(bitmap);
		}
	}
}

 

보꼬 (1,630 포인트) 님이 2015년 4월 8일 질문

1개의 답변

0 추천
https://github.com/nostra13/Android-Universal-Image-Loader

와 같은 라이브러리를 사용하면 더 간단하게 구현이됩니다.
nicehee (73,100 포인트) 님이 2015년 4월 8일 답변
...