Reputation: 11097
I am converting Bitmap into Drawable using following code.
MemoryCache memoryCache = new MemoryCache();
Bitmap bitmap = memoryCache.get(thumbnail);
Drawable drawable = (Drawable)new BitmapDrawable(bitmap);
The MemoryCache I have used is from LazyList Project and it works fine when I use bitmap but when I convert it to drawable then it shows nothing in place of image.
Please Help
Upvotes: 6
Views: 20366
Reputation: 777
Try using the following
Drawable d = new BitmapDrawable(bitmap);
Upvotes: 3
Reputation: 11097
Problem Found
Actually the problem was with
MemoryCache memoryCache = new MemoryCache();
Bitmap bitmap = memoryCache.get(thumbnail);
Upvotes: 0
Reputation: 30990
Change this line:
Drawable drawable = (Drawable)new BitmapDrawable(bitmap);
To:
Drawable drawable = new BitmapDrawable(getResources(), bitmap);
Note that the BitmapDrawable(Bitmap bitmap)
constructor has been deprecated (source) and using the above call apparently ensures it gets set correctly with the right target density.
Upvotes: 18