构造函数BitmapDrawable()已被弃用

时间:2014-11-09 19:01:08

标签: java android eclipse

我有一个扩展BitmapDrawable的类,如下所示:

public class MyDrawable extends BitmapDrawable {
    protected Drawable drawable;

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

并且Eclipse警告我不推荐使用构造函数BitmapDrawable()。一切都工作得很好,但我想修好课程,所以我不知道这个消息。

感谢任何帮助。

1 个答案:

答案 0 :(得分:7)

目前你的类有默认构造函数MyDrawable()调用BitmapDrawable(),不推荐使用!

向您的类添加一个带有两个参数(Resources和Bitmap)的构造函数,并调用超级构造函数:

 BitmapDrawable(context.getResources(), canvasBitmap);

这应该可以解决您的问题

相关问题