我已经破解了这段代码。它是一个水平列表视图。问题是正在加载相同的图像而不是不同的图像。可能是什么问题?我不认为毕加索是这里的问题。我想其他的东西。
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
// View timeLineRow = LayoutInflater.from(parent.getContext()).inflate(R.layout.dashboardtimelinerow, null);
if (convertView == null) {
LayoutInflater mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.toprecommendationsitem, parent, false);
holder = new ViewHolder();
holder.recommimage = (ImageView) convertView.findViewById(R.id.recommimage);
holder.userImage = (CircularImageView) convertView.findViewById(R.id.userImage);
convertView.setTag(holder);
} else
holder = (ViewHolder) convertView.getTag();
int i=0;
for(i=0; i<mArrayListData.size(); i++) {
if (!mArrayListData.get(i).getDishimageurl().isEmpty()) {
Picasso.with(mContext)
.load(mArrayListData.get(i).getDishimageurl())
.resize(172, 172)
.into(holder.recommimage);
break;
}
}
return convertView;
}
答案 0 :(得分:1)
您未在position
函数内的任何位置使用getView
的值。 getView
应该返回您传入的数组或列表中索引position
处的任何数据片段的视图。您需要用
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
LayoutInflater mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.toprecommendationsitem, parent, false);
holder = new ViewHolder();
holder.recommimage = (ImageView) convertView.findViewById(R.id.recommimage);
holder.userImage = (CircularImageView) convertView.findViewById(R.id.userImage);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
if (!mArrayListData.get(position).getDishimageurl().isEmpty()) {
Picasso.with(mContext)
.load(mArrayListData.get(position).getDishimageurl())
.resize(172, 172)
.into(holder.recommimage);
}
return convertView;
}