我使用Picasso在我的expandableListview上加载图片,但似乎图片缓存无效。
我的列表中有大量图像,每次向下滚动,我都会看到占位符。之前我使用过Universal Image Loader,当我已经加载图片时它没有显示占位符。
这是我的适配器以及我如何使用它:
...
@Override
public View getChildView(int groupPosition, int childPosition, boolean b, View convertView, ViewGroup viewGroup) {
final ChildViewHolder viewHolder;
mChild = (ArrayList<Item>) mChildWrapper.get(groupPosition);
Item item = mChild.get(childPosition);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.my_child_row, null);
viewHolder = new ChildViewHolder();
viewHolder.myImage = (ImageView) convertView.findViewById(R.id.my_img);
convertView.setTag(viewHolder);
} else {
viewHolder = (ChildViewHolder) convertView.getTag();
}
Picasso.with(mContext)
.load(item.getUrl())
.placeholder(R.drawable.my_placeholder)
.into(viewHolder.myImage, new Callback() {
@Override
public void onSuccess() {
viewHolder.myImage.setVisibility(View.VISIBLE);
}
@Override
public void onError() {
viewHolder.myImage.setVisibility(View.GONE);
}
});
return convertView;
}
...
static class ChildViewHolder {
...
private ImageView myImage;
...
}
我引用this post进行缓存,但它对我没用。我在这里做错了什么?