Fer*_*ago 7 android caching lazy-loading imageview picasso
我正试图在Picasso的背景下加载一个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);
Run Code Online (Sandbox Code Playgroud)
我的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) {}
};
Run Code Online (Sandbox Code Playgroud)
我想预先加载图像,这样我可以在用户单击按钮的任何时候在ImageView中逐个显示.
第一个图像加载速度很快(很酷)但是for循环中的其他图像永远不会加载.我怎样才能解决这个问题?我需要图像开始加载for循环.
我不得不使用:
Picasso.with(getActivity().getApplicationContext()).load(p.getImage()).fetch();
以下是参考:https://square.github.io/picasso/2.x/picasso/com/squareup/picasso/RequestCreator.html
归档时间: |
|
查看次数: |
8654 次 |
最近记录: |