我正在尝试使用Picasso在后台加载包含20个URL的数组。到目前为止,我有以下代码:
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循环中开始加载这些图像。