我在列表视图中再次显示 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;
}
}