1
웹에서 이미지로 목록보기를 작성합니다. 전에 다른 질문을했습니다. Android ListView with images from special hashmap. 하지만 이제 SimpleAdapter를 확장하려고했습니다. 해시 맵을 사용하여 데이터를 저장합니다. 그럼 난 새로운 "ImageAdapter"를 사용 :SimpleAdapter에서 setViewImage를 어떻게 사용할 수 있습니까?
public class ImageAdapter extends SimpleAdapter {
public ImageAdapter(Context context,
List<? extends Map<String, ?>> data, int resource, String[] from,
int[] to) {
super(context, data, resource, from, to);
// TODO Auto-generated constructor stub
}
@Override
public void setViewImage(ImageView v, String value) {
super.setViewImage(v, value);
URL url;
try {
url = new URL(value);
URLConnection conn = url.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
Bitmap bm = BitmapFactory.decodeStream(is);
v.setImageBitmap(bm);
} catch (Exception e) {
e.printStackTrace();
}
}
}
내 list.xml :
[...]
<ImageView
android:id="@+id/list_image"
android:layout_width="50dip"
android:layout_height="50dip" />
[...]
가이 오류입니다 - 그러나 이미지 뷰가/빈 흰색입니다! 데이터로 정의 된 이미지 (URL/URL)로 이미지 뷰를 채우려면 어떻게해야합니까?
ada = new ImageAdapter(getApplicationContext(), data, R.layout.list, new String[] {"imgurl", "title", "date", "ex", "id"}, new int[] {R.id.list_image, android.R.id.text1, android.R.id.text2, R.id.text3});
감사합니다. 나는 많은 변화를 시도 ...하지만 아무것도 작동 :(