我在listview中再次显示text1,image和text2。图像与text1相关。并非所有text1都包含图像。因此,如果text1包含图像,它将显示或不显示。 当图像存在时,text1,image和text2显示良好。但是当图像不存在时,则text2不显示。只有text1显示在列表中。 哪里出错了?请帮我解决这个问题......
我的代码:
public View getView(int position, View convertView, ViewGroup parent) {
--
---
---
---
((TextView) view.findViewById(R.id.text1)).setText(listItem.gettext1());
imageUrl = "http://server.com//folder/"+ ret.get(0);(ret.get(0) is the name of the image along with extension)
imView = (ImageView)view.findViewById(R.id.img);
drawable = LoadImageFromWebOperations(imageUrl);
imView.setImageDrawable(drawable);
((TextView) view.findViewById(R.id.text2)).setText(listItem.gettext2());
}
private Drawable LoadImageFromWebOperations(String url) {
try {
InputStream is = (InputStream) new URL(url).getContent();
Drawable d = Drawable.createFromStream(is, "src-name");
return d;
} catch (Exception e) {
System.out.println("Exc=" + e);
return null;
}
}