Bitmaps and throwIfRecycled exception

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Bitmaps and throwIfRecycled exception

Postby Drummkit » Tue Jul 21, 2009 4:06 pm

Hi,
I try to draw a Bitmap returned by the getDrawingCache method but it gives me a throwIfRecycled exception.
Here is my class :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. private static class AnimatingView extends View {
  3.  
  4.         private final Bitmap    mBitmap;
  5.  
  6.         final   GridView        mTab;
  7.  
  8.  
  9.  
  10.         AnimatingView(Context ctxt, GridView g) {
  11.  
  12.             super(ctxt);
  13.  
  14.             mTab = g;
  15.  
  16.             g.setDrawingCacheEnabled(true);
  17.  
  18.             mBitmap = g.getDrawingCache();
  19.  
  20.             g.setDrawingCacheEnabled(false);
  21.  
  22.         }
  23.  
  24.  
  25.  
  26.         @Override
  27.  
  28.         protected void onDraw(Canvas canvas) {
  29.  
  30.             canvas.save();
  31.  
  32.             canvas.drawColor(Color.WHITE);
  33.  
  34.             if (mBitmap != null) {
  35.  
  36.                 canvas.drawBitmap(mBitmap, new Matrix(), null);
  37.  
  38.             }
  39.  
  40.             canvas.restore();
  41.  
  42.         }
  43.  
  44.     }
  45.  
  46.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4

Is the bitmap deleted even if I have a reference on (mBitmap)? How can I do to get it right?
Thanks for your help,
Guillaume
Drummkit
Freshman
Freshman
 
Posts: 3
Joined: Wed Jul 15, 2009 2:43 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests