我正在尝试在 ListView 上显示图像。代码片段:
private String[] movieURL = {"..","..",".."};
try {
Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL(movieURL[position]).getContent());
holder.image.setImageBitmap(bitmap);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
这是 ViewHolder 类:
private static class ViewHolder {
public TextView text1;
public TextView text2;
public ImageView image;
}
但它什么也没显示。我认为代码没问题。和堆栈跟踪:
12-14 07:50:54.975: D/dalvikvm(1865): GC_CONCURRENT freed 122K, 8% free 3082K/3324K, paused 4ms+28ms, total 123ms
12-14 07:50:55.175: D/dalvikvm(1865): GC_FOR_ALLOC freed 16K, 8% free 3178K/3424K, paused 40ms, total 51ms
12-14 07:50:55.195: I/dalvikvm-heap(1865): Grow heap (frag case) to 4.291MB for 1127536-byte allocation
12-14 07:50:55.286: D/dalvikvm(1865): GC_FOR_ALLOC freed <1K, 6% free 4278K/4528K, paused 84ms, total 86ms
12-14 07:50:55.395: D/dalvikvm(1865): GC_CONCURRENT freed <1K, 6% free 4279K/4528K, paused 10ms+20ms, total 118ms
12-14 07:50:55.547: W/Trace(1865): Unexpected value from nativeGetEnabledTags: 0
12-14 07:50:55.625: W/Trace(1865): Unexpected value from nativeGetEnabledTags: 0
12-14 07:50:55.685: W/Trace(1865): Unexpected value from nativeGetEnabledTags: 0
12-14 07:50:55.715: W/Trace(1865): Unexpected value from nativeGetEnabledTags: 0
12-14 07:50:55.815: W/Trace(1865): Unexpected value from nativeGetEnabledTags: 0
12-14 07:50:57.125: D/skia(1865): --- SkImageDecoder::Factory returned null
12-14 07:50:57.875: D/skia(1865): --- SkImageDecoder::Factory returned null
12-14 07:50:58.736: D/skia(1865): --- SkImageDecoder::Factory returned null
12-14 07:50:59.386: D/skia(1865): --- SkImageDecoder::Factory returned null
12-14 07:50:59.945: D/skia(1865): --- SkImageDecoder::Factory returned null