I have a RecyclerView which is showing a CardView. In the CardView there are two items:
- TextView
- My custom view with underlying bitmap
The bitmap is created dynamical.
After some up and down scrolling I get an OutOfMemoryException.
I'm not sure how to handle it? Should I use LRUCache? Or third party libraries like Picasso - which seems to only work on urls and ids?
Any help appreciated
Update:
public class ManageProfileAdapter : RecyclerView.Adapter
{
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
{
ManageProfileViewHolder vh = holder as ManageProfileViewHolder;
vh.Caption.Text = profiles[position].Name;
vh.Thumbnail.SetProfile(profiles[position].Profile);
}
}
The thumbnail class is a custom class derived from View (which includes bitmap):
public class ThumbnailView : View
{
private Canvas DrawCanvas;
private Bitmap CanvasBitmap;
}
The bitmap is drawn on the Canvas.