0
我试图显示一个列表视图,其中包含以前从互联网上下载的图像以及一些信息。文字信息显示很好,但imageview不是。我的代码是:位图不会出现在ListView中
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Log.w("MyApp", "Getting View");
View row = convertView;
if(row==null){
LayoutInflater inflater=getLayoutInflater();
row=inflater.inflate(R.layout.list_item, parent, false);
}
ImageView showcase = null;
try{
showcase = new ImageView(ReadingList.this);
}catch(Exception e){
Log.w("MyApp", e.toString());
}
if(showcase!=null){
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 3;
Bitmap bm = null;
File dir = new File(PATH + urlIDs[position]);
if(dir.isDirectory()){
Log.w("MyApp","Dir is a directory");
for (File child : dir.listFiles()) {
String path = child.getAbsolutePath();
Log.w("MyApp", path);
bm = BitmapFactory.decodeFile(path, options);
Log.w("MyApp", "See if bm is null");
if(bm!=null){
Log.w("MyApp", "bm!=null");
showcase.setImageBitmap(bm);
break;
}
}
}
}
TextView title =(TextView)row.findViewById(R.id.list_item_text);
TextView url = (TextView) row.findViewById(R.id.list_item_url);
title.setText(Titles[position]);
url.setText(urlPrefixes[position]);
return row;
}
}
对不起它在此刻有点混乱。我可以在logcat中看到,因为它发现该文件夹中的图像,它通过bm!=null
检查,并应设置该图像作为如果我没有弄错ImageView的内容。我甚至可以在logcat中看到它已移到下一行项目,并且我可以使用eclipse文件管理器来查看实际上是否收到路径末尾的图像child.getAbsolutePath
我是什么做错了?