RecycledViewPool在
ViewPager+RecyclerView的场景下可以大放光彩。
下面就来验证一下它的优点:
首先我们自定定义一个View放在ViewHolder中:
public class FloorView extends ImageView {
//这里如果数组大于0可以放大FloorView的内存占用。
private Bitmap[] bitmaps=new Bitmap[0];
public FloorView(Context context) {
super(context);
init();
}
public FloorView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init();
}
public FloorView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init(){
for (int i = 0; i < bitmaps.length; i++) {
bitmaps[i]= BitmapFactory.decodeResource(getResources(),R.drawable.pic1);
}
Log.e("lmtlmt","init");
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();