我正在尝试使用毕加索在后台加载20个网址的数组。到目前为止,我有下一个代码:
Log.d("GAME", "Loading all images");
for (int i = gamePieces.length-1; i >= 0; i--) {
GamePiece p = gamePieces[i];
Log.d("GAME", "I will load " + p.getImage());
Picasso.with(context).load(p.getImage()).into(target);
}
//loading the first one
Picasso.with(context).load(piece.getImage()).into(target);
我的target
对象是下一个对象:
Target target = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
Log.d("GAME", "Image loaded" + ++test);
gameImage.setImageBitmap(bitmap); //ImageView to show the images
}
@Override
public void onBitmapFailed(Drawable arg0) {}
@Override
public void onPrepareLoad(Drawable arg0) {}
};
我想预加载图像,以便用户每次单击按钮时都可以在ImageView中一一显示。
第一个图像加载得太快了(太酷了),但是在for循环中的其他图像却从未加载过。我怎样才能解决这个问题?我需要图像开始在for循环中加载。
我不得不使用: Picasso.with(getActivity().getApplicationContext()).load(p.getImage()).fetch();
这是参考:https : //square.github.io/picasso/2.x/picasso/com/squareup/picasso/RequestCreator.html
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句