我正在尝试将图像加载到ListAdapter中的imageview。然而,当我将10个缩略图图像传递给listAdapter并在imageview中设置它们时,在imageview中只能看到1个或没有。正如我从文档中理解的那样,我不需要使用任何asyntask,因为毕加索库已经在asyntask工作了。你能帮我解决一下这个问题吗?
//像这样调用CustumListAdapter;
Get-Help Write-Host
Get-Help Write-Output
//这是我的CustomListAdapter类
CustomListAdapter customListAdapter = new CustomListAdapter(this, resultArrayList);
listView = (ListView) findViewById(R.id.listview_score);
listView.setAdapter(customListAdapter)
修改
我使用public class CustomListAdapter extends ArrayAdapter<String> {
private ArrayList<String> resultContent;
//private Integer[] imageid;
private Activity context;
public CustomListAdapter(Activity context, ArrayList<String> resultContent) {
super(context, R.layout.activity_ident_result2, resultContent);
this.context = context;
this.resultContent = resultContent;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View listViewItem = inflater.inflate(R.layout.activity_ident_result2, null, true);
if (position % 2 == 0) {
TextView textViewName = (TextView) listViewItem.findViewById(R.id.textView_score);
textViewName.setText(resultContent.get(position));
ImageView imageView = (ImageView) listViewItem.findViewById(R.id.imageView_score);
//imageView.setImageBitmap(IdentResultActivity.splittedBitmaps.get(position + 1));
Picasso.with(this.context).load(resultContent.get(position + 1)).into(imageView);
}
return listViewItem;
}
}
我可以看到一张图片没有问题,其余的是progress.png
EDIT2:
这是我的imageView xml文件;
.placeholder(R.drawble.progress)
答案 0 :(得分:0)
我认为inflater.inflate
的参数应为(R.layout.activity_ident_result2, parent, false)
答案 1 :(得分:-1)
你需要创建循环以将每个图像添加到[]然后你需要显示它。你发布的代码就是你只添加了一张图片。