제가 어떤 정보를 디비에서 가져와서
리스트뷰로 보여주려고 합니다.
각 리스트에는
이미지뷰, 텍스트뷰, 버튼 3가지가 들어갑니다.
현재 레이아웃은 완료 했는데
이미지 부분에서 문제가 생기네요
제가 원하는 방식은
각각의 리스트의 이미지 부분을
내용과 맞는 이미지로 넣고 싶은데요
처음에는
iv.setImageDrawable(mainCon.getResources().getDrawable(R.drawable.person1));
이 소스가 있었어요
그래서 이부분만 바꾸려고 하는데
그게 안되네요
//변수 선언
Bitmap imgBitmap = null;
ImageView ImageView1;
InputStream is;
URL aURL;
URLConnection conn;
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
final int pos = position;
if (convertView == null) {
convertView = Inflater.inflate(layout, parent, false);
}
//리스트안의 이미지뷰, 텍스트뷰 2개, 이미지버튼1개
ImageView iv = (ImageView) convertView.findViewById(R.id.imageView1);
TextView tv2 = (TextView) convertView.findViewById(R.id.textView2);
TextView tv3 = (TextView) convertView.findViewById(R.id.textView3);
favBtn = (ImageButton) convertView.findViewById(R.id.favoritebtn);
favBtn.setFocusable(false);
favBtn.setTag(position);
// String img에 이미지url을 저장
img = arDetail.get(position).imgurl;
Log.d("img", img);
try {
aURL = new URL("img);
} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
conn = aURL.openConnection();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
conn.connect();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
is = conn.getInputStream();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
BufferedInputStream bis = new BufferedInputStream(is);
imgBitmap = BitmapFactory.decodeStream(bis);
try {
bis.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
is.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
is = new URL("img).openStream();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
imgBitmap = BitmapFactory.decodeStream(is);
try {
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//imgBitmap = GetImageFromURL("img);
iv.setImageBitmap(imgBitmap);
tv2.setText(arDetail.get(position).medianame);
tv3.setText(arDetail.get(position).mediadetail);
return convertView;
}
//MyItem 은 String 변수 8개 묶음
MyItem mi;
al = new ArrayList<MyItem>();
//al 는 arraylist
do {
mi = new MyItem(
cursor.getString(cursor.getColumnIndex("menu")),
cursor.getString(1),
cursor.getString(2),
cursor.getString(3),
cursor.getString(4),
cursor.getString(5),
cursor.getString(6),
cursor.getString(7));
al.add(mi);
}
}
while (cursor.moveToNext());
이런식으로 짰는데
막상 불러오지를 못하네요
조언 부탁드립니다.




일단 링크를 읽어 보신 후
http://blog.naver.com/PostView.nhn?blogId=yohanyooo&logNo=40137290812
url 불러오는 부분을 onCreate 에서 한번만 처리 해주시고, 불러온 이미지를 array 변수에 담아
iv.setImageBitmap(mBitmap[position]); 요런식으로 처리해주셔도 될 것 같은데요.