我尝试过此代码,但未获得所需的输出。
Picasso.with(getApplicationContext()).load(mPicList.get(position)).into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
zoomImageView.setImageBitmap(bitmap);
Logger.getInstance().v("qw", "ViewPagerAdapter.134.onBitmapLoaded.");
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
Logger.getInstance().v("qw", "ViewPagerAdapter.139.onBitmapFailed.");
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
Logger.getInstance().v("qw", "ViewPagerAdapter.144.onPrepareLoad.");
}
});
它总是打印log onPrepareLoad为什么????
您的问题是,没有任何东西可以对目标实例保持强烈的引用,因此它会被垃圾回收。您不能只调用new Target(){...},因为对此没有任何强引用。您需要将其存储在视图持有者的字段中或在视图的子类上实现。
看到这个答案:
https://stackoverflow.com/a/30681395/5476209
这个家伙明确地管理了库中发生的垃圾回收问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句