The constructor of BitmapDrawable () is an obsolete fix.

I have a class that extends BitmapDrawable that looks like this:

public class MyDrawable extends BitmapDrawable {
    protected Drawable drawable;

    @Override
    public void draw(Canvas canvas) {
        if(drawable != null) {
            drawable.draw(canvas);
        }
    }
    // some other methods...
}

and Eclipse warns me that the constructor of BitmapDrawable () is deprecated. Everything is working fine, but I would like to fix my class, so I do not receive this message.

Any help is appreciated.

+4
source share
1 answer

Your class currently has a default constructor, MyDrawable (), which calls BitmapDrawable (), which is deprecated!

Add a constructor with two arguments (resources and bitmaps) to your class and call the super constructor:

 BitmapDrawable(context.getResources(), canvasBitmap);

this should solve your problem.

+7
source

All Articles