这是我从logcat中得到的错误
2019-07-06 22:59:15.486 29689-29689/com.example.devcash E/BitmapDrawable: Canvas: trying to use a recycled bitmap
2019-07-06 22:59:15.486 29689-29689/com.example.devcash W/System.err: java.lang.RuntimeException: Canvas: trying to draw too large(272250000bytes) bitmap.
2019-07-06 22:59:15.486 29689-29689/com.example.devcash W/System.err: at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:229)
我读过某个地方要添加recycle
吗?但是我不确定将其放在代码中的位置还是正确的做法。这是我的代码段:
@Override
public void onBindViewHolder(@NonNull InventoryRecyclerViewAdapter.ViewHolder viewHolder, final int i) {
Log.d(TAG, "onBindViewHolder: called.");
Glide.with(context)
.asBitmap()
.load(mIcon.get(i))
.into(viewHolder.icon);
viewHolder.label.setText(mLabel.get(i));
viewHolder.customLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG, "OnClick: clicked on: " + mLabel.get(i));
Toast.makeText(context, mLabel.get(i), Toast.LENGTH_SHORT).show();
}
});
}