ListView中的图像重复 [英] Images in ListView are repeated
问题描述
我解析VK的组墙。有些岗位照片(从1到10),一些不具备。我需要显示它们。然而,所有的图像被重复。我不能让他们正确显示。我使用的是毕加索的时刻。它说,它能够处理图像的ListView,但事实并非如此。我对谷歌foun其他方式都不能工作。现在的问题是如何正确地处理图像。这里是一块code的,负责的照片。
I'm parsing vk's group wall. Some posts have photos(from 1 to 10), some don't have. And I need to display them. However, all the images are repeated. And I can't make them appear correctly. I'm using Picasso at the moment. It says it can process ListView images, however it doesn't. Other ways I foun on google don't work either. The question is how to process images correctly. Here is a piece of code that is responsible for photo.
private void place_photos(View view, ArrayList<VKPhoto> photos) {
int pcount = photos.size();
final View v = view;
TableRow first = (TableRow)v.findViewById(R.id.first_row);
TableRow second = (TableRow)v.findViewById(R.id.second_row);
TableRow third = (TableRow)v.findViewById(R.id.third_row);
for (int i = 0; i < pcount; i++) {
if (i == 1) {
ImageView img = new ImageView(mContext);
String url = photos.get(i).photo_807;
img.setTag(url);
Picasso.with(mContext).load(url).into(img);
if (first != null)
first.addView(img);
}
if (i == 2 || i == 3) {
ImageView img = new ImageView(mContext);
String url = photos.get(i).photo_807;
img.setTag(url);
Picasso.with(mContext).load(url).into(img);
if (second != null)
second.addView(img);
}
if (i > 3) {
ImageView img = new ImageView(mContext);
String url = photos.get(i).photo_807;
img.setTag(url);
Picasso.with(mContext).load(url).into(img);
if (third != null)
third.addView(img);
}
}
}
这就是它是如何调用getView方法:
And that's how it's called in getView method:
if (post.attachments.hasPhoto) {
place_photos(v, post.attachments.photos);
} else {
viewHolder.photo_wrapper.setVisibility(View.GONE);
}
UPD
下面是完整的适配器code: https://gist.github.com/alexbat98/7f22598e7e73d301a4ef一>
推荐答案
尝试
ImageView img;
里面ViewHolder类,然后用它作为
inside ViewHolder class and then use it as
viewHolder.img = viewHolder.photo;
viewHolder.img.setTag(photo_100);
imageLoader.DisplayImage(photo_100, viewHolder.img);
这篇关于ListView中的图像重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!