我有图片链接,我使用Picasso下载并显示它。我可以显示ProgressBar以显示图片正在加载吗?
这是我的代码:
Picasso.with(mContext)
.load(MYurl.BASE_URL + "/" + getItem(position).getImgThumb())
.into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
finalViewHolder.asanaImg.setImageBitmap(bitmap);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
答案 0 :(得分:3)
在使用Picasso加载图像之前,必须先启动进度条。稍后你可以在加载或失败的回调中将其解除。
//start progressbar here
Picasso.with(mContext)
.load(MYurl.BASE_URL + "/" + getItem(position).getImgThumb())
.into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
finalViewHolder.asanaImg.setImageBitmap(bitmap);
//stop progressbar here
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
//stop progressbar here
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});