显示一个"载入中..."图像,同时图像毕加索的后台加载 [英] Show an "Loading..." image while background loading of image with Picasso
本文介绍了显示一个"载入中..."图像,同时图像毕加索的后台加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的毕加索的图像后台加载(列表视图和ImagePager)。我可以设置加载图像和errorimage与毕加索,但我无法在后台加载,以显示加载中形象。
I am using Picasso for background loading of images (list view and ImagePager). I can set loading image and errorimage with Picasso, but I am unable to show a "loading in progress" Image during background loading.
有没有人一个想法如何完成这件事?在我PagerAdapter类,我有以下方法:
Has anybody an idea how to get this done? In my PagerAdapter Class I have the following method:
@Override
public Object instantiateItem(ViewGroup container, int position) {
ImageView imageView = new ImageView(context);
int padding = context.getResources().getDimensionPixelSize(R.dimen.padding_medium);
imageView.setPadding(padding, padding, padding, padding);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
// Set default Image before loading real image
imageView.setImageResource(R.drawable.img_def);
imageView.setId(imgViewId);
imageView.setClickable(true);
imageView.setOnClickListener(this);
((ViewPager) container).addView(imageView, 0);
// Set default Image before loading real image
Picasso.with(context).load(R.drawable.img_def).into(imageView);
// Load real image with Picasso and show error image if failed
Picasso.with(context).load(GalImgUrls[position]).error(R.drawable.no_img).into(imageView);
return imageView;
}
然而,它并没有显示正在加载...的形象。任何解决方案/想法?
However, it does not show the "loading..." image. Any solutions/ideas?
谢谢!
推荐答案
看起来像我找到了解决自己。使用占位符的形象:
Looks like I found a solution myself. Use "placeholder" image:
Picasso.with(context).load(tnu).error(R.drawable.no_img).placeholder(R.drawable.img_def).into(holder.immoPic);
作品般的魅力......
Works like charm....
这篇关于显示一个"载入中..."图像,同时图像毕加索的后台加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文